surfstudio / flutter-otp-autofill

Made by Surf 🏄
Apache License 2.0
75 stars 42 forks source link

Error receiving broadcast intent #17

Closed Chinmay-KB closed 1 year ago

Chinmay-KB commented 2 years ago
E/AndroidRuntime(26204): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=in.kreateworld.debug (has extras) } in ru.surfstudio.otp_autofill.SmsRetrieverReceiver@130b2f0
E/AndroidRuntime(26204):    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1590)
E/AndroidRuntime(26204):    at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
E/AndroidRuntime(26204):    at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(26204):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(26204):    at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime(26204):    at android.app.ActivityThread.main(ActivityThread.java:7705)
E/AndroidRuntime(26204):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(26204):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime(26204):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
E/AndroidRuntime(26204): Caused by: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(26204):    at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:286)
E/AndroidRuntime(26204):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:267)
E/AndroidRuntime(26204):    at ru.surfstudio.otp_autofill.OTPPlugin$registerSmsRetrieverBroadcastReceiver$1$1.onSuccess(OTPPlugin.kt:181)
E/AndroidRuntime(26204):    at ru.surfstudio.otp_autofill.SmsRetrieverReceiver.onReceive(SmsRetrieverReceiver.kt:24)
E/AndroidRuntime(26204):    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1580)
E/AndroidRuntime(26204):    ... 8 more

Describe the bug

Once OTP sms is received, the app crashes completely. Code used is the same as that given in the example.

Additional context

I have forked this repo and added try catch around the android code, and upgraded the dependency versions in gradle, and it is working. That is not the proper way to do this though, just an emergency workaround.

aadarsh-patel commented 2 years ago

I fixed it by setting timeout to 0 in FirebaseAuth,

    await firebaseAuth.verifyPhoneNumber(
        phoneNumber: phoneNumber,
        timeout: Duration(seconds: 0),
        verificationCompleted: phoneVerificationCompleted,
        verificationFailed: phoneVerificationFailed,
        codeSent: phoneCodeSent,
        forceResendingToken: forceResendCode,
        codeAutoRetrievalTimeout: autoRetrievalTimeout);

Answer taken from https://stackoverflow.com/a/69078728/11555932

BLUECALF commented 1 year ago

Hello, @Chinmay-KB Did you find a way around the issue

Chinmay-KB commented 1 year ago

Hello, @Chinmay-KB Did you find a way around the issue

Nope. Last I worked on this, I just made a fork of this project and wrapped the whole thing in try catch, worked for me

BLUECALF commented 1 year ago

Let me try wrapping and see if it works.

BLUECALF commented 1 year ago

I tried wrapping the otpinteractor.startListenRetiver on a try catch block and the error even cant be caught by the catch block.

BLUECALF commented 1 year ago

I changed the package to "sms_autofill: ^2.2.0" and it works for me. it seems this OTP-autofill pkg, has a method not doing its work. the stop-listen method. it is supposed to stop listening after a timeout or after like 5 min. but it didn't stop listening.

plasticfiresam commented 1 year ago

Seems like there is a stale issue, if it will occure again, new issue will be created