所以我一直在努力使推送插件(https://github.com/phonegap/phonegap-plugin-push)在iOS上工作一段时间(我对iOS开发一无所知)。它似乎正确地注册了设备,但是当我通过pushwatch发送通知时它会毫无问题地发送给Apple,但我没有收到任何东西(就像Android的魅力一样)。
它可以在Android上工作,我可以将通知发送给Apple让我觉得问题在于证书。我已经生成了应用程序ID并启用了推送通知,为生产和开发创建了推送证书(它们都没有工作)和开发的配置文件。
在Xcode上我已经从偏好/代理/下载全部下载了配置文件(这是我认为我搞乱了这一点)我可以使用自动构建设置构建应用程序而没有任何问题。当我在我的iPhone上运行应用程序时,我得到一个设备令牌,所以我知道它注册了设备。
这是我的index.js(我正在使用推送插件模板应用程序)
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
console.log('Received Device Ready Event');
console.log('calling setup push');
if(device.platform == "Android"){ //Android
console.log('Android');
var pushNotification = window.plugins.pushNotification;
pushNotification.register(app.successHandler, app.errorHandler, {"senderID":"XXX","ecb":"app.onNotification"});
}
else if(device.platform == "iOS"){ //iOS
console.log('iOS');
var pushNotification = PushNotification.init({
"android": {
"senderID": "XXX"
},
"ios": {
"badge":"true",
"sound":"true",
"alert":"true",
"ecb":"onNotification"
},
"windows": {}
});
}
},
// result contains any message sent from the plugin call
successHandler: function(result) {
console.info('Callback Success! Result = '+result)
},
errorHandler:function(error) {
console.info(error);
},
onNotification:function(e) {
push.on('registration', function(data) {
console.log('registration event: ' + data.registrationId);
var oldRegId = localStorage.getItem('registrationId');
if (oldRegId !== data.registrationId) {
// Save new registration ID
localStorage.setItem('registrationId', data.registrationId);
// Post registrationId to your app server as the value has changed
}
});
push.on('error', function(e) {
console.log("push error = " + e.message);
});
push.on('notification', function(data) {
console.log('notification event');
navigator.notification.alert(
data.message, // message
null, // callback
data.title, // title
'Ok' // buttonName
);
});
}};
好像我可以发送通知但是apns不知道发送它的位置或者发送它但是我的设备因为没有链接到证书而无法接收它。
提前谢谢。
修改 按照本教程中的步骤似乎解决了我的问题。 https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/ 我认为问题是密钥要求你写的短语。一旦我将其删除,通知就会开始显示。
答案 0 :(得分:0)
按照本教程中的步骤似乎解决了我的问题。 https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/我认为问题是密钥要求你写的短语。一旦我将其删除,通知就会开始显示。