The SMS User Consent API complements the SMS Retriever API by allowing an app to prompt the user to grant access to the content of a single SMS message. When a user gives consent, the app will then have access to the entire message body to automatically complete SMS verification.
$ yarn add @kyivstarteam/react-native-sms-user-consent
- React Native 0.60+
CLI autolink feature links the module while building the app.
- React Native <= 0.59
$ react-native link @kyivstarteam/react-native-sms-user-consent
import SMSUserConsent from '@kyivstarteam/react-native-sms-user-consent';
interface SMSMessage {
receivedOtpMessage: string
}
getSMSMessage = async () => {
try {
const message: SMSMessage = await SMSUserConsent.listenOTP()
} catch (e) {
// error
}
}
removeSmsListener = () => {
try {
SMSUserConsent.removeOTPListener()
} catch(e) {
// error
}
}