Giter Site home page Giter Site logo

don-isdale / readsmscordovaplugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dimitrismistriotis/readsmscordovaplugin

0.0 2.0 0.0 113 KB

A plugin to read text messages / SMSes using apache Cordova, developed against version 2.3.0, modified for version 3.4.0.

Java 100.00%

readsmscordovaplugin's Introduction

ReadSmsCordovaPlugin

A plugin to send SMSes using apache Cordova, developed against version 2.3.0

Setup

(1) Copy Java file from src folder to the src folder or your project. (2) In config.xml (under "res/xml"), register the plugin (see also "res/xml/config.additional.xml"):

    <plugin name="ReadSms" value="net.webootu.cordova.plugin.ReadSms" />

(3) Add the following lines in your AndroidManifest.additional.xml (see also AndroidManifest.additional.xml):

<!-- Additional permission for ReadSms plugin -->
<uses-permission android:name="android.permission.READ_SMS" />

(4) Call can be made using the Cordova plugin invocation/interface:

// GetTexts action:
cordova.exec(function(winParam) {}
    , function(error) {}
    , "ReadSms"
    , "GetTexts"
    , [phoneNumber, numberOfTextsToRead]);
// GetTextsAfter action:
cordova.exec(function(winParam) {}
    , function(error) {}
    , "ReadSms"
    , "GetTextsAfter"
    , [phoneNumber, timeStamp]);

Read Actions section for input parameters.

Actions

Currently there are two actions available, "GetTexts" and "GetTextsAfter".

GetTexts

"GetTexts" is being called with two parameters: mandatory phoneNumber and optional numberOfTextsToRead.

  • First parameter "phoneNumber" is the number of the phone from which we want to read texts messages from. This means messages stored in the inbox of the user's phone. Please also note that Android distinguishes between numbers containing the international "+" sign, so "+9999999999" is different from "09999999999" (leading zero).
  • Second parameter is "numberOfTextsToRead". A positive integer is used for maximum results returned, while a non-positive one is used to flag that all stored messages will be retrieved. Prefer to use "-1" instead of a random negative number of zero, in order to make your code future proof from possible extensions.

Results are being retrieved in descending order on time received, so last one will be the first one to be retrieved, etc.

GetTextsAfter

"GetTextsAfter" accepts two mandatory followed by two optional parameters. Mandatory ones are "phoneNumber" followed by "timeStamp". Specifically:

  • "phoneNumber", as in "GetTexts" is the phone number as described above (mandatory).
  • Phone number is followed by the time stamp in Unix epoch format, after which received texts will be returned (mandatory).

Results

Successful results contain a JSON object with the following properties in case of success: phone/_number: the number provided (echoed). texts: Retrieved texts. Each one of these has two properties, time stamp in "time_received" and SMS/text's payload in "message".

Examples

There is a sample execution in "assets/www/index.sample.html".

cordova.exec(function(winParam) {}, function(error) {}, "ReadSms", "GetTexts", ["999999999999", -1]);

Will try to read all texts from number "999999999999".

Sample output:

{
  "texts":[
    {
      "message":"ETA 20.02 ",
      "time_received":"1358538770262"
    },
    {
      "message":"Ok, I'm on my way.",
      "time_received":"1358536046947"
    }
  ],
  "phone_number":"999999999999"
}
cordova.exec(function(winParam) {}, function(error) {}, "ReadSms", "GetTexts", ["999999999999", 1]);

Will try to read all the last (since "numberOfTextsToRead" is 1) text from number "999999999999".

Sample output:

{
  "texts":[
    {
      "message":"Ok, I'm on my way.",
      "time_received":"1358536046947"
    }
  ],
  "phone_number":"999999999999"
}

Notes

In case you are interested in dispatching texts/Sms messages, refer to this plugin's sibling: SendSmsPlugin, using the same semantics, under the same license.

License

Please refer to LICENSE file in this repository.

Note

Initially by Dimitrios of WeBootU please consider us for your Cordova related projects.

readsmscordovaplugin's People

Contributors

dimitrismistriotis avatar don-isdale avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.