oohyugi / sms_otp_auto_verify

MIT License
9 stars 29 forks source link

Paytm screen exits automatically after getting OTP with sms_otp_auto_verify exception #15

Closed MaheshPeri19 closed 3 years ago

MaheshPeri19 commented 3 years ago

Hi,

I am using sms_otp_auto_verify latest version. I am having app crash issue after paytm OTP getting and exiting from paytm screen, connection lost to device.

I think sms_otp_auto_verify and paytm packages are clashing each other and getting below exception.

D/AssistLogs( 7053): com.paytm.pgsdk.PaytmPGActivity$SmsConsentBroadCastReciever@1efb186:Receiver started: D/AssistLogs( 7053): easypay.actions.EasypayBrowserFragment$11@9dc12e2:SMS consent:intent received D/AssistLogs( 7053): easypay.actions.EasypayBrowserFragment$11@9dc12e2:SMS consent:started D/AndroidRuntime( 7053): Shutting down VM E/AndroidRuntime( 7053): FATAL EXCEPTION: main E/AndroidRuntime( 7053): Process: com.user.myappname, PID: 7053 E/AndroidRuntime( 7053): java.lang.RuntimeException: Unable to start receiver com.oohyugi.sms_otp_auto_verify.SmsBroadcastReceiver: kotlin.TypeCastException: null cannot be cast to non-null type kotlin.String E/AndroidRuntime( 7053): at android.app.ActivityThread.handleReceiver(ActivityThread.java:4440) E/AndroidRuntime( 7053): at android.app.ActivityThread.access$1500(ActivityThread.java:301) E/AndroidRuntime( 7053): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147) E/AndroidRuntime( 7053): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime( 7053): at android.os.Looper.loop(Looper.java:246) E/AndroidRuntime( 7053): at android.app.ActivityThread.main(ActivityThread.java:8443) E/AndroidRuntime( 7053): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 7053): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596) E/AndroidRuntime( 7053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) E/AndroidRuntime( 7053): Caused by: kotlin.TypeCastException: null cannot be cast to non-null type kotlin.String E/AndroidRuntime( 7053): at com.oohyugi.sms_otp_auto_verify.SmsBroadcastReceiver.onReceive(SmsBroadcastReceiver.kt:28) E/AndroidRuntime( 7053): at android.app.ActivityThread.handleReceiver(ActivityThread.java:4431) E/AndroidRuntime( 7053): ... 8 more I/Process ( 7053): Sending signal. PID: 7053 SIG: 9 Lost connection to device. Exited (sigterm)

Please help me on this.

MaheshPeri19 commented 3 years ago

Issue is not related to paytm sdk. It is with this package sms_otp_auto_verify.

In sms_otp_auto_verify ====> SmsBroadcastReceiver.kt file ===>  line no 28, change from below line

val sms: String? = extras.get(SmsRetriever.EXTRA_SMS_MESSAGE) as String
to this line.
val sms: String? = extras.get(SmsRetriever.EXTRA_SMS_MESSAGE) as? String

Just added question mark after "as" solved this issue.

anup-geeky commented 3 years ago

@MaheshPeri19 How you fixed this issue? I am getting same issue with razorpay

MaheshPeri19 commented 3 years ago

@anup-geeky

Please try to find "SmsBroadcastReceiver.kt" file in razorpay sdk. If found, try to find below line.

val sms: String? = extras.get(SmsRetriever.EXTRA_SMS_MESSAGE) as String

If this line also found, then change to below line, thats it.

val sms: String? = extras.get(SmsRetriever.EXTRA_SMS_MESSAGE) as? String

Here just we are making that sms string to optional by adding question mark after "as" to that.

Hemanth10081999 commented 3 years ago

@MaheshPeri19 do you know the right way of doing this as i am using CI/CD pipeline which will automatically get the dependencies.

Edit: After an hour found that the SMS permission is not allowed by the user and added a permission check before getting into Paytm transaction. (Proceed only if the user accepts the permission)

MaheshPeri19 commented 3 years ago

@Hemanth10081999

I got this issue in paytm. After research, i found that the issue was at sms_otp_auto_verify package. Above lines solved my issue. I dont know native android code.

Hemanth10081999 commented 3 years ago

@MaheshPeri19 i added an edit to my comment :)