Play Store 512

Cordova SMS Receive plugin demo

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.

Apache Cordova logo phonegap

Overview

This Cordova demo app implements the SMS Receive plugin to get any received SMS from the device. Notice that this requires SMS permission granted by the user. Additionally, the SMS permission for Play Store submitted apps now requires the app to be set as the default SMS manager, and a permission declaration must be submitted and approved by the store,

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 / emulator
  • SMS permission granted by the user (prompted on first run)
  • Play Store apps: app set as default SMS manager + permission declaration approved

Screenshots

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

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.