A react native wrapper for the SMS User Consent API to request user consent to read a single SMS verification message. If the user consents, the API returns the text of the message, from which you can get the verification code and complete the verification process.
NPM:
npm install rn-dynamic-app-icon
YARN:
yarn add rn-dynamic-app-icon
import { getOtp, getSms, SMSRetrieverErrors } from 'rn-android-sms-retriever';
// Read the next SMS
const readNextSmsRequest = async () => {
try {
const sms = await getSms();
} catch (e) {
if (e.toString().includes(SMSRetrieverErrors.CONSENT_DENIED)) {
console.log('User denied SMS read request');
}
}
};
// Read OTP from SMS
const readNextOtpRequest = async (otpLength) => {
try {
const sms = await getOTP(otpLength); //Can only read numeric OTP values
} catch (e) {
if (e.toString().includes(SMSRetrieverErrors.REGEX_MISMATCH)) {
readNextOtpRequest(otpLength);
}
}
};
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Built by true-hamid & mustfaibra