jaumard / sms_autofill

Flutter plugin to provide SMS code autofill support
MIT License
289 stars 184 forks source link

PlatformException, Can't start sms retriever #169

Open vineetpandit90 opened 2 years ago

vineetpandit90 commented 2 years ago

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError PlatformException(ERROR_START_SMS_RETRIEVER, Can't start sms retriever, null, null). Error thrown null. StandardMethodCodec.decodeEnvelope (message_codecs.dart:607)

MethodChannel._invokeMethod (platform_channel.dart:177) SmsAutoFill.listenForCode (sms_autofill.dart:35)

memishood commented 1 year ago

same problem here Device: Samsung SM-G781W

einatguri commented 1 year ago

Any idea if and when this will be fixed ? right now the package is useless..

adityayocket commented 1 year ago

Not working on android 13 also. Is this because anything change in google privacy policy?

mohanK22 commented 11 months ago

The same crash is reported in our Firebase crashlytics Dashboard.

Crash Log -

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(ERROR_START_SMS_RETRIEVER, Can't start sms retriever, null, null)
       at StandardMethodCodec.decodeEnvelope(message_codecs.dart:652)
       at MethodChannel._invokeMethod(platform_channel.dart:310)
       at SmsAutoFill.listenForCode(sms_autofill.dart:35)

Usually, a PlatformException crash comes when the platform interaction fails.

As the crash crash begins from the below line - https://github.com/jaumard/sms_autofill/blob/master/lib/sms_autofill.dart#L35

The above code should be wrapped inside a try-catch block as it is communicating with the platform.

  try {
    await _channel.invokeMethod('listenForCode',
        <String, String>{'smsCodeRegexPattern': smsCodeRegexPattern});
  } on PlatformException catch (e) {
    // handle PlatformException here
  }

reference - https://docs.flutter.dev/platform-integration/platform-channels?tab=type-mappings-kotlin-tab#example-client

Please let us know once the fix is available.