科尔多瓦pushPlugin不工作的ios
问题描述:
林与科尔多瓦pushPlugin工作了一段时间 和所有其他时间插件: https://github.com/phonegap-build/PushPlugin 伟大的工作。科尔多瓦pushPlugin不工作的ios
但现在它甚至不要求发送通知的权限。 你有什么想法是什么错? 我试图安装,如果在3个应用程序,问题仍然存在,它真的像他们更新了一个版本,并没有一个错误。
谢谢
答
我最初有一些问题,但现在它工作正常。尝试下面的代码,这是非常自我解释。
这也适用于iOS 8!我想最初我正在尝试一些其他方法,在此期间我注册了iOS 8应用程序,所以当我插入插件时,注册部分不再需要,现在我也可以在iOS 8上获得完美的通知。
我在iOS 7面临的两个问题是,即使在我点击并打开应用程序并且没有显示徽章之后,通知仍未从状态栏清除。
var pushNotification;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
console.log("ON DEVICE READY!!!");
navigator.splashscreen.hide();
$("#app-status-ul").append('<li>deviceready event received</li>');
document.addEventListener("backbutton", function(e)
{
$("#app-status-ul").append('<li>backbutton event received</li>');
if($("#home").length > 0)
{
// call this to get a new token each time. don't call it to reuse existing token.
//pushNotification.unregister(successHandler, errorHandler);
e.preventDefault();
navigator.app.exitApp();
}
else
{
navigator.app.backHistory();
}
}, false);
try
{
pushNotification = window.plugins.pushNotification;
$("#app-status-ul").append('<li>registering ' + device.platform + '</li>');
if (device.platform == 'android' || device.platform == 'Android' || device.platform == 'amazon-fireos')
{
pushNotification.register(successHandler, errorHandler, {"senderID":"XXXXXXXXXXXXX","ecb":"onNotification"}); // required!
}
else
{
pushNotification.register(tokenHandler, errorHandler, {"badge":"true","sound":"true","alert":"false","ecb":"onNotificationAPN"}); // required!
}
}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
alert(txt);
console.log(txt);
}
}
// onDeviceReady之外这部分()
function tokenHandler (result)
{
console.log("token:"+result);
// $("#app-status-ul").append('<li>token: '+ result +'</li>');
// Your iOS push server needs to know the token before it can push to this device
// here is where you might want to send it the token for later use.
}
function successHandler (result)
{
console.log("in succ handler:"+result);
// $("#app-status-ul").append('<li>success:'+ result +'</li>');
}
function errorHandler (error)
{
console.log("in errorhandler:"+error);
// $("#app-status-ul").append('<li>error:'+ error +'</li>');
}
如果你使用的是iOS 8则可能是因为该插件还不支持它。在XCode的调试窗口中,您可能会看到类似以下错误:'iOS8.0及更高版本不支持registerForRemoteNotificationTypes :'和'试图标记应用程序图标,但未收到用户的许可来标记应用程序。请参阅:https://github.com/phonegap-build/PushPlugin/issues/364 – Ade 2014-10-12 12:51:47