[英]Ionic Push Notifications with Ionic.cloud
我正在嘗試使用官方網站( https://docs.ionic.io/services/push/ )中的文檔來實現Ionic(1)的推送通知服務,但是我不知道如何檢索,注冊並將令牌保存在我的Ionic App中。 你能幫助我嗎?
我想您已經安裝了具有正確配置的phonegap-plugin-push
插件,並使用正確的配置(如官方文檔中所述)將您的應用程序注冊到Ionic.io平台 。
因此,在您的app.js
,您可以這樣編寫:
/* 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);
}
然后, Ionic.io平台使您可以輕松地向所有注冊的設備發送通知。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.