1.0.1 • Published 9 years ago
ionic-push v1.0.1
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
jwtstring required A valid ionic jwtprofilestring required A valid ionic profileoptionsobject optional Options object.options.Promisepromise 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
optionsobject required A valid ionic push object
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
uuidobject required A valid ionic push uuid
Returns
A Promise.
Example
checkStatus(myuuid).then(function(data) {
console.log(data);
}).catch(function(err) {
console.log('there is an error', err);
});