A node client for pushing android and ios notifications to your ionic app.
npm install --save ionic-push
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);
Create a new IonicPush instance.
-
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.
An IonicPush instance.
import IonicPush from 'ionic-push';
const ionic = new IonicPush(myJwt, myProfile);
Test if your token is valid.
A Promise.
ionic.testToken().then(function() {
console.log('my token is ok');
}).catch(function(err) {
console.log('there is an error', err);
});
Push a new notification.
options
object required A valid ionic push object
A Promise.
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);
});
Check the status of a notification.
uuid
object required A valid ionic push uuid
A Promise.
checkStatus(myuuid).then(function(data) {
console.log(data);
}).catch(function(err) {
console.log('there is an error', err);
});