sms_autofill icon indicating copy to clipboard operation
sms_autofill copied to clipboard

SmsAutoFill.listenForCode throw PlatformException

Open nhan-nguyen-se opened this issue 4 years ago • 2 comments

The library works great in most cases. But sometimes I got below exception when calling SmsAutoFill.listenForCode:

PlatformException(ERROR_START_SMS_RETRIEVER, Can't start sms retriever, null, null)

Anyone else is facing the similar issue? Is it a good idea to retry listen for code in this case?

Anyway, the exception does not give me the details of the error. Can SmsAutoFillPlugin.java be improved to pass the error detail back to flutter? Currently it passes the error details as null:

task.addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {
        result.error("ERROR_START_SMS_RETRIEVER", "Can't start sms retriever", null);
    }
});

nhan-nguyen-se avatar Mar 03 '21 04:03 nhan-nguyen-se

Seems like a good idea. I'll take a look next week to see if we can at least include the exception message so we can debug it further. You can always open a PR if you beat me to it.

grahamsmith avatar Mar 04 '21 12:03 grahamsmith

Seems like a good idea. I'll take a look next week to see if we can at least include the exception message so we can debug it further. You can always open a PR if you beat me to it.

On the other hand, could this line not be invoked when on the web ?

  Future<void> get listenForCode async {
     // if (kIsWeb) return;
    await _channel.invokeMethod('listenForCode');
  }

Else your widget throws an error on the web and there is no way this method is going to be available on the web when not a phone.

cedvdb avatar Mar 12 '21 10:03 cedvdb