Demo app for testing the cordova-plugin-sms-receive, which allows to receive and read SMS messages using the Telephony API provided by Android. Source code available in GitHub.
Overview
This Cordova demo app implements the SMS Receive plugin to get any received SMS from the device. Requires SMS permission granted by the user.
For OTP verification messages, it is recommended use the SMS Retriever plugin instead, which does not require SMS permissions
Prerequisites
- Android 5.1 or higher device or emulator
Screenshots
- Android permission request dialog
- SMS watching started
- Incoming SMS retrieved
Methods
This is a summary of the demo app’s methods. Refer to plugin’s README for details
startWatch
Start listening for incoming SMS messages. This will request SMS permission to the user if not yet granted.
Remarks
- Both success and error callbacks will react to SMS arrival events as well.
- Android 5.1 grants permission by default because the individual permission request dialog was added in Android 6.
stopWatch
Stops listening for incoming SMS. Always invoke this method after you have received the required SMS to prevent memory leaks.
Events
onSMSArrive
Triggered when a new SMS has arrived. You need call startWatch first.
Remarks
- Success in reading incoming SMS will trigger the startWatch success callback.
- Failure in reading incoming SMS will trigger the startWatch error callback.
Download demo app
- Download debug APK v1.0.2 (minSdkVersion 22)
- Download www source code
Feedback
Use the comments section here for demo app-related issues, and the GitHub Issues tracker for plugin-related ones.