ionic-push

1.0.1 • Public • Published

npm version Build Status Dependency Status devDependency Status

ionic-push

A node client for pushing android and ios notifications to your ionic app.

Install

npm install --save ionic-push

Usage

import IonicPush from 'ionic-push';
 
const ionic = new IonicPush(myJwt, myProfile);
 
ionic.push({
    "tokens": ["your", "device", "tokens"],
    "notification": {
     "title": "Hi",
     "message": "Hello world!",
    "android": {
     "title": "Hey",
        "message": "Hello Android!"
    },
    "ios": {
        "title": "Howdy",
        "message": "Hello iOS!"
    }
  }
});

require

var IonicPush = require('ionic-push').default;
 
var ionic = new IonicPush(myJwt, myProfile);

Api

new IonicPush

Create a new IonicPush instance.

Arguments

  • jwt string required A valid ionic jwt

  • profile string required A valid ionic profile

  • options object optional Options object.

  • options.Promise promise optional Promise to overwrite for requests.

Returns

An IonicPush instance.

Example
import IonicPush from 'ionic-push';
 
const ionic = new IonicPush(myJwt, myProfile);

testToken

Test if your token is valid.

Returns

A Promise.

Example

ionic.testToken().then(function() {
    console.log('my token is ok');
}).catch(function(err) {
    console.log('there is an error', err);
});

push

Push a new notification.

Arguments

Returns

A Promise.

Example

ionic.push({
    "tokens": ["your", "device", "tokens"],
    "notification": {
     "title": "Hi",
     "message": "Hello world!",
    "android": {
     "title": "Hey",
        "message": "Hello Android!"
    },
    "ios": {
        "title": "Howdy",
        "message": "Hello iOS!"
    }
  }
}).then(function() {
    console.log('successfully sent push');
}).catch(function(err) {
    console.log('there is an error', err);
});

checkStatus

Check the status of a notification.

Arguments

Returns

A Promise.

Example

checkStatus(myuuid).then(function(data) {
    console.log(data);
}).catch(function(err) {
    console.log('there is an error', err);
});

Package Sidebar

Install

npm i ionic-push

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • leopradel