1.0.1 • Published 7 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
jwt
string required A valid ionic jwtprofile
string required A valid ionic profileoptions
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
options
object 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
uuid
object 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);
});