gpt4 book ai didi

android - 应用程序打开时推送通知不显示 Pushwoosh - Phonegap

转载 作者:行者123 更新时间:2023-11-29 02:18:29 32 4
gpt4 key购买 nike

我正在使用 Pushwoosh 在 Phonegap 中发送通知,但是如果我在应用程序中,Android 和 iOS 都不会显示通知。

我该如何解决?

我浏览了几个链接,但没能搞清楚。

   function initPushwoosh()
{

var pushNotification = window.plugins.pushNotification;

if (device.platform == "Android")
{

//set push notifications handler
document.addEventListener('push-notification', function(event) {
var title = event.notification.title;
var userData = event.notification.userdata;

if (typeof (userData) != "undefined") {
console.warn('user data: ' + JSON.stringify(userData));
}


});

//initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady({projectid: "", appid: ""});


//register for pushes
pushNotification.registerDevice(
function(status) {
var pushToken = status;

localStorage.setItem("deviceid", pushToken);

console.warn('push token: ' + pushToken);
},
function(status) {
console.warn(JSON.stringify(['failed to register ', status]));
}
);



}
else if (device.platform == "iOS")
{
//set push notification callback before we initialize the plugin
document.addEventListener('push-notification', function(event) {
//get the notification payload
var notification = event.notification;
navigator.notification.alert(notification.aps.alert);


//clear the app badge
pushNotification.setApplicationIconBadgeNumber(0);
});

//initialize the plugin
pushNotification.onDeviceReady({pw_appid: ""});

//register for pushes
pushNotification.registerDevice(
function(status) {
var deviceToken = status['deviceToken'];
localStorage.setItem("deviceid", deviceToken);




},
function(status) {
console.warn('failed to register : ' + JSON.stringify(status));

}
);


//reset badges on app start
pushNotification.setApplicationIconBadgeNumber(0);
}
}



function init()
{

document.addEventListener("deviceready", initPushwoosh, true);
// document.addEventListener("backbutton", onBackKeyDown, false);
// Cordova is ready to be used!
}

最佳答案

使用强制显示

var push = PushNotification.init(
{ "android": {"senderID": "533867441597", "forceShow": "true"
},
"ios": {"alert": "true", "badge": "true", "sound": "true"
}

});

关于android - 应用程序打开时推送通知不显示 Pushwoosh - Phonegap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28453269/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com