npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-sms-receive

v2.0.0

Published

Cordova plugin to receive SMS in Android

Downloads

1,039

Readme

License Platform Donate

cordova-plugin-sms-receive

Cordova plugin to get received SMS contents in Android platform.

Installation

Add the plugin from NPM:

cordova plugin add cordova-plugin-sms-receive

Methods

startWatch

Start listening for incoming SMS messages. This will request SMS permission to the user if not yet granted.

:warning: Method moved from window to cordova.plugins object in version 2.0.0

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.

Success callback return values

  • SMS_WATCHING_STARTED
  • SMS_WATCHING_ALREADY_STARTED
  • SMS_RECEIVED: Second callback, triggered when a SMS was received.

Error callback return values

  • PERMISSION_DENIED: User declined the permission request.
  • SMS_EQUALS_NULL: Triggered after watching started OK but plugin failed to read the received SMS.
  • Any other error string for failed SMS retrieval whenever an SMS is received.

Example

cordova.plugins.SMSReceive.startWatch(function(strSuccess) {
	console.log(strSuccess);
}, function(strError) {
	console.warn(strError);
});

stopWatch

Stops listening for incoming SMS. Always invoke this method after you have received the required SMS to prevent memory leaks.

Success callback return values

  • SMS_WATCHING_STOPPED

Example

cordova.plugins.SMSReceive.stopWatch(function(strSuccess) {
	console.log(strSuccess);
}, function(strError) {
	console.warn(strError);
});

Events

onSMSArrive

Triggered when a new SMS has arrived. You need call startWatch first.

:warning: JSON SMS payload moved from message.data to message object in version 2.0.0

Remarks

  1. Success in reading and parsing incoming SMS trigger the success callback from startWatch.
  2. Failure in reading or parsing incoming SMS trigger the error callback from startWatch.

Example

document.addEventListener('onSMSArrive', function(message) {
	console.log('address:' + message.address);
	console.log('body:' + message.body);
	console.log('date' + message.date)
});

Plugin demo app

You can download the compiled SMS Receive plugin demo app and inspect the source code in my plugin demos repository.

ScreenShot

FAQ

Can the SMS be intercepted and deleted?

This plugin does not send SMS nor intercept incoming SMS: the intercepting feature has been removed in Android 5 or earlier for security concerns, so no plugin can do this anymore.

Does the plugin still work with the app minimized?

When the app is sent to the background, as long as Android has not unloaded it to recover memory, SMS watching will remain active and working correctly.

Android Permissions Request

The startWatch method will cause the Android 6.0 and higher permission dialog to show up with this message:

Allow [AppName] to send and view SMS messages?

This message is not exactly accurate, because the plugin only requests permission for receiving SMS as follows:

<uses-permission android:name="android.permission.RECEIVE_SMS" />

How this plugin has been tested?

This plugin has been successfully tested in devices and emulators ranging from Android 5.1 to Android 10.

Contributing

If you find any bugs or want to improve the plugin, kindle subtmit a PR and it will be merged as soon as possible.

Even if you don't quite understand Java, you can investigate and locate issues with the plugin code by opening the SMSReceive.java file and browsing StackOverflow or the Android APIs documentation with the proper keywords.

Changelog

2.0.0

  • :warning: Methods moved from the global window to the cordova.plugins object.
  • :warning: onSMSArrive no longer returns result in the message.data object, use message directly
  • Fixed SMS message body, now returns the entire message without 154 chars limit.
  • Fixed error when trying to start SMS watching when already active.
  • Changed the onSMSArrive invoking method internally to use native PluginResult callback.
  • Removed the SMS service center number from the JSON payload.
  • Improved all methods return values to make them easier to parse.
  • Improved error handling.
  • Updated demo app, now available as pre-compiled APK.