hanatharesh2712 / ionic-native-sms-retriever-plugin-master

Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
27 stars 18 forks source link

SMS Read function is not working on the android version above android26 #27

Closed sivamurugan03 closed 2 years ago

sivamurugan03 commented 3 years ago

SMS retriever function is working only on the android version 26 and below. But it is not working on the android version above android26. Is there any fix for this issue?

Thanks in advance.

hanatharesh2712 commented 3 years ago

@sivamurugan03 What issue are you facing? please add details about the issue and environment you are using

JIBIN-P commented 3 years ago

I would like to add few details to this issue, I couldn't try android 26, but I tried this on android 31 and the appHash is getting generated successfully, but the following code is not getting executed when a message arrives.

this.platform.ready().then(() => {
      this.smsRetriever
        .startWatching()
        .then((res: any) => {
          const otpMessage = res.Message.toString();
          const regex = /[0-9]{6,6}/g;
          const extractOtp = otpMessage.match(regex).toString();
          console.log(extractOtp);
          alert(extractOtp);
          console.log(res);
        })
        .catch((error: any) => console.error(error));
    });

My setup is "@capacitor/core": "^2.4.5", "@ionic-native/core": "^5.30.0", "@angular/common": "^11.0.0", "cordova-plugin-sms-retriever-manager": "1.0.2", "@ionic-native/sms-retriever": "^5.33.1",

Please let me know if I can help in any way.

hanatharesh2712 commented 3 years ago

@sivamurugan03 You can find the working example with target android version 30 and ionic 5: https://github.com/hanatharesh2712/sms-plugin-test-ionic-5