I'm trying to implement the push notification service of Ionic (1) using the docs from official site ( https://docs.ionic.io/services/push/ ), but i don't understand how can i retrieve, register and save the token on my Ionic App. Can you help me?
I suppose you have the phonegap-plugin-push
plugin installed with the the correct configuration and register your application to Ionic.io platform with also the correct configuration (like describe in the official documentation).
So, in your app.js
, you can write this :
/* PUSH */
//If cordova is installed
if(window.cordova){
var push = new Ionic.Push({
"debug": false,
"onNotification": function(notification) {
//Do something when you receive a notification
console.log(notification);
}
});
var callback = function(pushToken) {
//Save the token specified to the device
//this token is saved in the Ionic.io database
push.saveToken(pushToken.token);
}
//register you device to your app notification system
push.register(callback);
}
Then the Ionic.io platform allows you to send notifications easily to all the devices registered.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.