通过 Worklight 发送推送通知时,我面临以下问题。
- 推送消息长度非常有限 - 大约 65 个字符
- 在设备上接收到的有效负载消息已删除所有间距
就像我发送了“这是一条测试消息”,但在设备上它收到了“ Thisisatestmessage ”
现在,特别是工作灯中推送消息的限制大小是多少,我知道苹果公司说 256 字节。但是 Worklight 允许什么?
以及为什么有效负载正在删除空格。即使我正在从后端 java 服务发送消息
我的推送适配器:
function generalNotification(userId, msgTitle, MsgContents, org, logo){
var userSubscription = WL.Server.getUserNotificationSubscription('aahadPushAdapter.GeneralPushSource', userId);
if (userSubscription==null){
return { result: "No subscription found for user :: " + userId };
}
WL.Logger.debug("Sending Push >> userId:: " + userId + ", Message:: " + MsgContents);
WL.Server.notifyAllDevices(userSubscription, {
badge: 1,
sound: "sound.mp3",
activateButtonLabel: "Read",
alert: msgTitle,
payload: {
msg : MsgContents,o:org,l:logo
}
});
return { result: "Notification sent to user :: " + userId };
}
我的后端 Java 代码:
DataAccessService service = WorklightBundles.getInstance().getDataAccessService();
String parm = "['" + userID + "','"+ msgTitle + "','"+ msgContents+ "','"+org + "','"+logo +"']";
ProcedureQName pushMethod = new ProcedureQName("aahadPushAdapter","transNotification");
InvocationResult results = service.invokeProcedure(pushMethod, parm);
jsonObj = results.toJSON();
msg = "Push Sent successfully to " + userID + " " + (String)jsonObj.get("");
请检查此代码并提出建议,如果此处缺少某些内容?
谢谢