akvelon / react-native-sms-user-consent

React Native wrapper for Android's SMS User Consent API, ready to use in React Native apps with minimum effort.
Other
89 stars 40 forks source link

black screen when the native dialogue opens #2

Closed sriksm19 closed 3 years ago

sriksm19 commented 3 years ago

Hi

thanks for making this library. I installed your lib on my app (RN 0.64.1, on a pixel 1 android 10), (also had to do manual linking to make it work) when i receive an sms, then whole screen turns black when the consent dialogue tries to come up.. meanwhile, i also get a warning firebase.crashlytics().recordError(*) expects an instance of Error. Non Errors will be ignored. just before it goes blank.

edited: also, one funny thing i noticed is that, when i added the hook on the first screen of the app, the consent screen works fine, but once i navigate (using react navigation) to another page, the above mentioned problem comes up

any clue why this would be happening?

Thanks in advance

edit:

i tried to log the error. got this: java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=com.myapp (has extras) } in com.google.android.gms.internal.firebase-auth-api.zzvl@6cc189e at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1560) at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference at java.util.regex.Matcher.reset(Matcher.java:280) at java.util.regex.Matcher.<init>(Matcher.java:186) at java.util.regex.Pattern.matcher(Pattern.java:1034) at com.google.android.gms.internal.firebase-auth-api.zzvn.zzb(com.google.firebase:firebase-auth@@21.0.1:1) at com.google.android.gms.internal.firebase-auth-api.zzvl.onReceive(com.google.firebase:firebase-auth@@21.0.1:8) at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1550) ... 8 more

eabdullazyanov commented 3 years ago

Hi @sriksm19,

Thank you for your feedback on this library. From your message I can point out two problems:

  1. Auto-linking isn't working, so you have to make manual linking.
  2. It goes to black screen when the consent popup is about to appear, but not on the root screen.

Unfortunately, I wasn't able to reproduce any of the two using Pixel 1 emulator with Android 10 and React Native v0.64.1.

We need some more information in order to reproduce the issue.

  1. Are you using an emulator or a real device?
  2. Your environment info - output of the "npx react-native info" command.
  3. Minimal repro app. We can first focus on one of the two issues if you prefer.
sriksm19 commented 3 years ago
  1. Using a real device.. also tested it on android 11 Pixel 4a. same thing.. only a particular page has the problem
  2. System: OS: macOS 11.4 CPU: (8) arm64 Apple M1 Memory: 86.28 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.0.0 - ~/.nvm/versions/node/v16.0.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v16.0.0/bin/yarn npm: 7.10.0 - ~/.nvm/versions/node/v16.0.0/bin/npm Watchman: Not Found Managers: CocoaPods: 1.10.1 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 29, 30 Build Tools: 29.0.2, 30.0.2 System Images: android-29 | Google APIs Intel x86 Atom, android-S | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7351085 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.64.1 => 0.64.1 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found
    1. tried to get it on a sample app.. works well there.. the problem is quite funny as the page on which i require ur plugin is the only one thats crashing and the on rest where its not required it runs well šŸ˜·
sriksm19 commented 3 years ago

ok i somehow narrowed it down to this: I use RNFirebase to login using phone number. Since nowhere in their docs are there any proper steps mentioned on how to do a successful SMS auto retrieval (i even tried using other libs to try get the SMS auto retrieval working, all in vain), went with the sign in then enter otp manually kinda flow. turns out, on whichever screens ive called the auth().signinwithphonenumber(..) method, this lib crashes.. and hence the logged error i mentioned in the 1st msg of the thread. what i am guessing is that firebase is secretly listening to SMS for autoretrieval (at which it still does a bad job as of now), and ur lib n firebase are kinda clashing for the listening intent (i dunno how native works.. just sherlocking it here). still figuring out the root cause. would get back once i get something. thanks a lot

eabdullazyanov commented 3 years ago

Hi @sriksm19,

Were you able to make further progress on the issue investigation?

sriksm19 commented 3 years ago

nope. nothing yet. it became a low priority, and i ran out of leads wrt firebase. hence i couldnt give much attention to it

eabdullazyanov commented 3 years ago

Closing this issue due to insufficient reproduction info and long time inactivity. Please, let us know if you manage to find some more details on this.

sriksm19 commented 2 years ago

Looks like this is the issue. https://stackoverflow.com/questions/65803670/error-receiving-broadcast-intent-when-using-smsretriever

I patched my rn firebase package and now it works fine!

all I did was change the value of the timeout values in PhoneAuthProvider.getInstance functions from 60 to 0 within the signInWithPhoneNumber method inside the node_modules/@react-native-firebase/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java

Could you include it in the readme as a note for firebase users?

sriksm19 commented 2 years ago

@eabdullazyanov This is the diff:

diff --git a/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java b/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java
index 1ce9e72415f1822ed792f6843af9a49cae75d16a..d7ef368bd3bb74a375b084838c03bc97a8d2ffa4 100644
--- a/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java
+++ b/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java
@@ -902,10 +902,10 @@ class ReactNativeFirebaseAuthModule extends ReactNativeFirebaseModule {
       if (forceResend && mForceResendingToken != null) {
         PhoneAuthProvider.getInstance(firebaseAuth)
             .verifyPhoneNumber(
-                phoneNumber, 60, TimeUnit.SECONDS, activity, callbacks, mForceResendingToken);
+                phoneNumber, 0, TimeUnit.SECONDS, activity, callbacks, mForceResendingToken);
       } else {
         PhoneAuthProvider.getInstance(firebaseAuth)
-            .verifyPhoneNumber(phoneNumber, 60, TimeUnit.SECONDS, activity, callbacks);
+            .verifyPhoneNumber(phoneNumber, 0, TimeUnit.SECONDS, activity, callbacks);
       }
     }
   }