Demo app for testing the cordova-plugin-sms-retriever, which allows to receive and read SMS messages using the SMS Verification APIs provided by Android. Source code available in GitHub.
Overview
Open the app, get the hash string, click startWatch and send yourself a sample SMS before the 5 minute API timeout is reached.
Prerequisites
- Google Play Services enabled (use Google Play APIs system image in emulator)
Screenshots
- Hash string queried
- SMS retriever started
- Incoming SMS retrieved
Methods
getHashString
Get the 11-character hash string for your app using the AppSignatureHelper class. This string must be appended to the SMS received in order for the API to read this message. The hash will be different from debug and release builds, since they have different signatures.
A sample SMS will be generated with the returned hash string. Copy this message and send it to your device ater invoking the startWatch method.
Remarks
- The requisite for the <#> prefix was silently removed from the SMS Retriever API in an unknown version. To ensure backwards compatibility, keep including it.
- Calling this method while an active SMS retriever is running will void the retriever and the SMS won’t be retrieved, therefore demo app prevents this action.
startWatch
Start listening for a single incoming verification SMS for 5 minutes. This will later raise the onSMSArrive event when a valid SMS arrives.
- When a valid SMS is intercepted, the SMS watching is stopped.
- After 5 minutes, SMS watching is stopped and the failure callback returns TIMEOUT.
When and SMS is returned, the SMS retriever API is automatically stopped and no further messages will be intercepted until you start a new one. This is by API design, not a plugin or a demo app’s restriction.
Events
onSMSArrive
Event fired when a valid SMS is received and read by the SMS retriever API. The received SMS will be shown in the Status section.
Download demo app
- Download APK v1.2.1 (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.