ion-sms-retrieved
Implement Android SMS retrived
Install
npm install ion-sms-retrieved
npx cap sync
Example
// register to SMS receiver when screen appear
AndroidSmsRetrieved.registerSmsReceiver();
// unregister from SMS receiver when screen dissappear
AndroidSmsRetrieved.unregisterSmsReceiver();
// get otp from sms
AndroidSmsRetrieved.startSmsUserConsent().then(({ otp }) => {
this.oneTimeCode = otp;
});
API
registerSmsReceiver()
registerSmsReceiver() => any
Returns: any
unregisterSmsReceiver()
unregisterSmsReceiver() => any
Returns: any
startSmsUserConsent()
startSmsUserConsent() => Promise<{ otp: string; }>
Returns: Promise<{ otp: string; }>
Ref
Auto read otp android user consent api
Build capacitor plugin
Custom Native Android Code
Create implementation in plugin