среда: jquery mobile 1.0, ios 8.1 ipad (не е хакнат), cordova
Искам да покажа push notification permission alert
. Опитах се да следвам много решения, но не можах да го накарам да работи. Започвам насочено известие, използвайки този код:
function on_load() {
document.addEventListener("deviceready", function(){
$.mobile.showPageLoadingMsg();
console.log(device.platform);
i_platform = device.platform.toUpperCase();
if(device.platform.toUpperCase() == 'ANDROID'){
window.plugins.pushNotification.register(successHandler,errorHandler, {
"senderID" : "378913173898", "ecb" : "onNotificationGCM"});
} else {
window.plugins.pushNotification.register(tokenHandler, errorHandler, {
"badge":"true", // 뱃지 기능을 사용한다.
"sound":"true", // 사운드를 사용한다.
"alert":"true", // alert를 사용한다.
"ecb": "onNotificationAPN" });
}
});
}
function onNotificationAPN (event){
if (event.alert){
navigator.notification.alert(event.alert);
}
if (event.sound){
var snd = new Media(event.sound);
snd.play();
}
if (event.badge){
window.plugins.pushNotification.setApplicationIconBadgeNumber(successHandler, errorHandler, event.badge);
}
}
function tokenHandler(result){
//alert('deviceToken:' + result);
ongetregidios(result);
}
function errorHandler(err){
alert('error:' + err);
}
function successHandler(result){
// alert('result:'+result);
}
In appdeletete.m
:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
Но не показва предупреждение за натискане при първо стартиране. Благодаря за всяка помощ.
successHandler
,errorHandler
,onNotificationGCM
и т.н...... - person Ajoy   schedule 17.08.2015