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

react-native-android-sms

v0.0.1

Published

A react native android module to list/send sms.

Downloads

7

Readme

Sms for react-native android

A react native android module to list/send sms.

Setup

There are five steps in the setup process.

  1. Install the module via npm.
  2. Update android/settings.gradle file.
  3. Update android/app/build.gradle file.
  4. Register the module in MainActivity.java file.
  5. Rebuild and restart package manager
  • Install the module via npm
 npm i --save react-native-android-sms
  • Update android/settings.gradle file
...
include ':react-native-android-sms'
project(':react-native-android-sms').projectDir = new File(settingsDir, '../node_modules/react-native-android-sms')
  • Update android/app/build.gradle file
...
dependencies {
    ...
    compile project(':react-native-android-sms')
}
  • Register the module (in MainActivity.java file)
import my.qash.react.SmsPackage;  // <--First, we import import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {

  ......
  private static Activity mActivity = null;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mActivity = this;
    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new SmsPackage(this))      // <------- Then, we add the package
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

     mReactRootView.startReactApplication(mReactInstanceManager, "MyExampleApp", null);

    setContentView(mReactRootView);
  }

  ......

}
  • Run react-native run-android from your project root directory

Usage

  • List all SMS messages matching filters.
var SmsAndroid = require('react-native-android-sms');

/* List SMS messages matching the filter */
var filter = {
    box: 'inbox', // 'inbox' (default), 'sent', 'draft', 'outbox', 'failed', 'queued', and '' for all
    // the next 4 filters should NOT be used together, they are OR-ed so pick one
    read: 0, // 0 for unread SMS, 1 for SMS already read
    _id: 1234, // specify the msg id
    address: '+97433------', // sender's phone number
    body: 'Hello', // content to match
    // the next 2 filters can be used for pagination
    indexFrom: 0, // start from index 0
    maxCount: 10, // count of SMS to return each time
};

SmsAndroid.list(JSON.stringify(filter), (fail) => {
        console.log("OH Snap: " + fail)
    },
    (count, smsList) => {
        console.log('Count: ', count);
        console.log('List: ', smsList);
        var arr = JSON.parse(smsList);
        for (var i = 0; i < arr.length; i++) {
            var obj = arr[i];
            console.log("Index: " + i);
            console.log("-->" + obj.date);
            console.log("-->" + obj.body);
        }
    });

/* 
Each sms will be represents by a JSON object represented below

{
  "_id": 1234,
  "thread_id": 3,
  "address": "2900",
  "person": -1,
  "date": 1365053816196,
  "date_sent": 0,
  "protocol": 0,
  "read": 1,
  "status": -1,
  "type": 1,
  "body": "Hello There, I am an SMS",
  "service_center": "+60162999922",
  "locked": 0,
  "error_code": -1,
  "sub_id": -1,
  "seen": 1,
  "deletable": 0,
  "sim_slot": 0,
  "hidden": 0,
  "app_id": 0,
  "msg_id": 0,
  "reserved": 0,
  "pri": 0,
  "teleservice_id": 0,
  "svc_cmd": 0,
  "roam_pending": 0,
  "spam_report": 0,
  "secret_mode": 0,
  "safe_message": 0,
  "favorite": 0
}

*/

  • Send an SMS
var SmsAndroid = require('react-native-android-sms');
var text = "Hello ... QASH I AM YOUR FATHER !!!!!";
var addressList = {
    addressList: [
        "+97433------", "+97434------"
    ]
}

SmsAndroid.send(JSON.stringify(addressList), text, (fail) => {
        console.log("OH Snap: " + fail)
    },
    (status) => {
        console.log('Status: ', status);
    });
  • Delete an SMS (coming soon)