$ npm install react-native-sms-retriever-api --save
$ react-native link react-native-sms-retriever-api
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNSmsRetrieverPackage;
to the imports at the top of the file - Add
new RNSmsRetrieverPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-sms-retriever-api' project(':react-native-sms-retriever-api').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sms-retriever-api/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-sms-retriever-api')
Start listening for OTP/SMS. Return true if listener starts else throws error.
Gets the hash code for the application which should be added at the end of message. This is just a one time process.
Adds a javascript listener to the handler passed which is called when message is received.
Removes the listener.
import RNSmsRetriever from 'react-native-sms-retriever-api';
// TODO: What to do with the module?