Cordova SMS retriever demo app

Cordova SMS Retriever plugin demo

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.

Apache Cordova logo phonegap

Overview

To test this plugin, open the app, get the hash string, click startWatch and send yourself a sample SMS before the 5 minute API timeout is reached. The app will intercept and read its contents, then show it in the provided textarea control.

Prerequisites

  • Google Play Services enabled (use Google Play APIs system image in emulator)

Screenshots

Methods

This is a summary of the demo app’s methods. Refer to plugin’s README for details

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

Feedback

Use the comments section here for demo app-related issues, and the GitHub Issues tracker for plugin-related ones.

More plugin demos

Check out the following Cordova plugin demo apps ready for download on your device. The source code is included for compiling to any platform.

Disclaimer

The content in this post is for general information purposes only. The information is provided by the author and/or external sources and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the post for any purpose. Some of the content and images used in this post may be copyrighted by their respective owners. The use of such materials is intended to be for educational and informational purposes only, and is not intended to infringe on the copyrights of any individuals or entities. If you believe that any content or images used here violate your copyright, please contact us and we will take appropriate measures to remove or attribute the material in question.