My app crashes on android 14when auto reading otp

Hi everyone,

I’m facing an issue with my Android app update being rejected by the Play Store.

Problem: I’ve added these permissions to support OTP reading:

xml

Copy code

<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
  • Without these, the app crashes on Android 14 when auto-reading OTP.
  • On Android 13 and below, OTP auto-read works fine.

Need Help:

  • Has anyone else dealt with this issue?
  • Any advice on getting these permissions approved?
  • Tips on handling OTP auto-reading for Android 14 without rejection?

Thanks in advance!

Please provide more information.

  • Assuming you are using Capacitor? Which version?
  • What plugin or code are you using to auto-read OTP?
  • What is the rejection error/message from the Play Store?

Hello Tom
I am using cordova version 12
This is the code I am using for auto read otp
this is in the ts class:

getSMS() {
if (this.platform.ready()) {
const smsRetriever: any = window.cordova.plugins.smsRetriever;
smsRetriever.startWatching((res) => {
this.showConfirmButton = true;
let smsTextmessage = res.Message.split(" “)[4].split(”.")[0];
this.otpCode = smsTextmessage;
console.log("started watching #### ", res);
this.cd.detectChanges();
}, (err) => {
console.warn("an error occured #### ", err);
});
}
}

and this is in the component html

Enter OTP code sent to {{ msisdn }}

<ion-button
icon-left
size=“medium”
expand=“full”
shape=“round”
color=“primary”
(click)=“validate()”
[disabled]=“!showConfirmButton”
tappable>
Validate

Didn’t receive a code? Resend.

I also have this method in the app component
requestPermissions() {
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_SMS).then(
result => {
if (!result.hasPermission) {
this.androidPermissions.requestPermissions([
this.androidPermissions.PERMISSION.READ_SMS,
this.androidPermissions.PERMISSION.RECEIVE_SMS
]);
}
},
err => {
this.androidPermissions.requestPermissions([
this.androidPermissions.PERMISSION.READ_SMS,
this.androidPermissions.PERMISSION.RECEIVE_SMS
]);
}
);
}

and i have called it the initialization of the app
The error that I am getting on playstore is that the update was rejected
Earlier on playstore they were saying that my app uses the following undeclared SMS and call log permissions


and so on the permissions declaration form I selected on the Call based OTP account verification and on the instructions for review response:I said that the app uses the READ_SMS and RECEIVE_SMS permissions to automatically read OTP messages sent to the user for account verification purposes. This functionality enhances user experience by eliminating the need for manual entry of OTP codes.

Please use proper code blocks so we can easily read your code - Extended Syntax | Markdown Guide

What Cordova plugin are you using? A link to the repo or NPM preferred.

Sorry about that.I have formatted the code.
I am using Cordova plugin sms retriever manager

Are you on the latest version 1.0.5? There is an open issue about this - App Crashing on Android 14 while trying to getSMS · Issue #42 · hanatharesh2712/ionic-native-sms-retriever-plugin-master · GitHub where it was supposedly fixed in the latest version.

It has to do with broadcasts in Android 14 requiring an intention being set - android - One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts - Stack Overflow

Thanks Tom let me check it out.

Updated the cordova-plugin-sms-retriever-manager to the latest version and now its okay.

1 Like