在 Worklight 中,我为 iOS 设置了推送消息,它工作正常。现在出于测试目的,当我通过 URL 调用发送推送时,消息标题正确,而正文(有效负载)部分截断所有空格并将所有单词一起显示。
例如:
http://mydomain/myApp/invoke?adapter=aaPushAdapter&procedure=sendPush¶meters=["aahad","General Title 2", "This is General message body 2"]
然后,标题为“General Title 2”,正文部分为“ThisisGeneralmessagebody2”
我的适配器声明为:
function sendPush(userId, msgTitle, MsgContents){
var userSubscription = WL.Server.getUserNotificationSubscription('aaPushAdapter.PushEventSource', userId);
if (userSubscription==null){
return { result: "No subscription found for user :: " + userId };
}
WL.Server.notifyAllDevices(userSubscription, {
badge: 1,
sound: "sound.mp3",
activateButtonLabel: "Read",
alert: msgTitle,
payload: {
msg : MsgContents
}
});
return { result: "Notification sent to user :: " + userId };
}
(1) 现在我怎样才能保留这种格式?
(2) 如果我必须发送 URL,那么我如何格式化和发送我的消息?
请建议。谢谢