Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Work in Android 12 #105

Open
EHRdev opened this issue May 19, 2022 · 13 comments
Open

Not Work in Android 12 #105

EHRdev opened this issue May 19, 2022 · 13 comments

Comments

@EHRdev
Copy link

EHRdev commented May 19, 2022

Hello, I have been using the library for a long time and it is a great tool.

But yesterday my phone was upgraded to Android 12 and it seems it needs additional permission:

MicrosoftTeams-image

@gusapc
Copy link

gusapc commented Jun 7, 2022

Hello, I have the same problem, did you find a solution?

@EHRdev
Copy link
Author

EHRdev commented Jun 7, 2022

I'm sorry, I found the solution but it's in native language (Java), since I'm not good at that language I haven't been able to adapt it in React Native, I was hoping that the creator of the library would help us.

SOLUTION IN JAVA: https://stackoverflow.com/questions/71285519/telephonymanager-listen-not-working-after-targetsdkversion-is-set-to-31-or-andro

@computerjazz
Copy link

@EHRdev thanks for the SO link, here's a patch that incorporates it: https://gist.github.com/computerjazz/a2214c50b36cbb81f4a64e3405e9b60d

@EHRdev
Copy link
Author

EHRdev commented Jun 22, 2022

@EHRdev thanks for the SO link, here's a patch that incorporates it: https://gist.github.com/computerjazz/a2214c50b36cbb81f4a64e3405e9b60d

woooow bro, thank you very much, this is really great, thanks for sharing, I would never have been able to do it myself.

I had the opportunity to try it and it no longer gives an error <3, however it does not detect the events (Offhook, Disconnected, etc.), I use the code as it is in the documentation:

startListenerTapped = () => {
    this.callDetector = new CallDetectorManager((event, phoneNumber)=> {
      if (event === 'Offhook') {
        console.log('Offhook')
      }
      ...
}

@computerjazz
Copy link

computerjazz commented Jun 22, 2022

as of android SDK 31 you now also need to request READ_PHONE_STATE permission or else this will silently fail/noop. See the end of the linked SO post: https://stackoverflow.com/a/71789261

you may need to install react-native-permissions or a similar package.

@EHRdev
Copy link
Author

EHRdev commented Jun 22, 2022

as of android SDK 31 you now also need to request READ_PHONE_STATE permission or else this will silently fail/noop. See the end of the linked SO post: https://stackoverflow.com/a/71789261

you may need to install react-native-permissions or a similar package.

I really appreciate the help friend, hopefully the creator of the library can apply the patch soon

@EHRdev EHRdev closed this as completed Jun 22, 2022
@dprevost-LMI
Copy link

I have just encountered this problem today, I used the patch suggested and it worked. However, I wonder why this patch was never applied and a version 1.10.0 was not delivered and that also this issue is closed?

@EHRdev
Copy link
Author

EHRdev commented Jun 30, 2022

I have just encountered this problem today, I used the patch suggested and it worked. However, I wonder why this patch was never applied and a version 1.10.0 was not delivered and that also this issue is closed?

Apparently the library's creator abandoned the project, android 12 has existed since last year with this problem and a few days ago the master computerjazz was the one who created the patch, I closed the issue myself because it solved the problem, but you're right, there should be a patch 1.10 that I doubt will arrive soon

@Invictus-Munish
Copy link

Bro I am getting error in ContextCompat

`D:\munish\Desktop\Invictus\jra\node_modules\react-native-call-detection\android\src\main\java\com\pritesh\calldetection\CallDetectionManagerModule.java:60: error: cannot find symbol
telephonyManager.registerTelephonyCallback(ContextCompat.getMainExecutor(reactContext), callStateListener);
^
symbol: method getMainExecutor(ReactApplicationContext)
location: class ContextCompat
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.`

@Vantam1601
Copy link

telephonyManager.registerTelephonyCallback(reactContext.getMainExecutor(), callStateListener);

@marcesengel
Copy link
Collaborator

@priteshrnandgaonkar would you mind pushing the update to npm if I prepare it or give me push access to the npm repo? https://www.npmjs.com/~marces

@marcesengel marcesengel reopened this Nov 21, 2022
@imamrobani
Copy link

@EHRdev what device are you using?
because I also got an error in Crashlytic about that, but when I tried to reproduce it in the emulator it didn't happen

@saurabh-sentieo
Copy link

Again not working for Android 13 (API=33). READ_PHONE_STATE permission is always never_ask_again for this version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants