我正在为Android和iOS开发cordova(3.4.0)应用程序。我正在整合城市飞艇推送通知。我从服务器发送推送消息和额外的url。在android中,推送信息和额外内容都是正确的,但我在iOS中收到的是空的额外内容。我正在跟踪城市飞艇phonegap文档http://docs.urbanairship.com/build/phonegap.html
接收推送和附加代码
var handleIncomingPush = function(event) {
if(event.message) {
console.log("Incoming push: " + event.message)
//alert(event.message);
} else {
console.log("No incoming message")
}
if(event.extras.url) {
console.log("URL")
window.open(event.extras.url,'_blank','location=no,closebuttoncaption=Done,toolbar=yes,toolbarposition=bottom');
}
}
Playload是
Payload: {"aliases":["alias_xssh"],"aps":{"badge":"+1","extra":{"url":"http://jhe.com/task.php?action=daily&username=ins-mobile&date=2014-05-12"},"alert":"This is subject"}
在xcode中接收时,日志为
aps = {
alert = "This is subject";
badge = 16;
extra = {
url = "http://jhe.com/task.php?action=daily&username=ins-mobile&date=2014-05-12";
};
};
2014-05-13 20:00:36.072 ListCreator[974:60b] {"message":"This is subject","extras":{}}
问题在最后一行。extras:{} is empty
。同样的代码在Android中正常运行,但在iOS中没有得到额外的。
如有任何建议,我将不胜感激。
谢谢
有效载荷应该像
Payload: "aps": {"alert": "This is subject", "badge": 1}, "url": "http://jhe.com/task.php?action=daily&username=ins-mobile&date=2014-05-12"
console.log(event.extras.url);
希望能有所帮助