Ibm mobilefirst 在Worklight中创建自定义推送通知
是否有一种方法可以在打开推送通知时将用户引导到另一个html页面Ibm mobilefirst 在Worklight中创建自定义推送通知,ibm-mobilefirst,Ibm Mobilefirst,是否有一种方法可以在打开推送通知时将用户引导到另一个html页面 感谢您的高级支持。如果您想查看,可以在common\js\main.js中看到以下内容: function pushNotificationReceived(props, payload) { alert("pushNotificationReceived invoked"); alert("props :: " + JSON.stringify(props)); alert("payload :: " +
感谢您的高级支持。如果您想查看,可以在common\js\main.js中看到以下内容:
function pushNotificationReceived(props, payload) {
alert("pushNotificationReceived invoked");
alert("props :: " + JSON.stringify(props));
alert("payload :: " + JSON.stringify(payload));
}
此函数告诉应用程序显示3个警报,告诉我们:
- 收到推送通知
- 它的道具
- 其有效载荷
- 了解如何使用或选择任何其他框架。。。()
下面是一个小例子。
以下是我对推送通知示例项目所做的修改: common\css\main.css
添加了一个成功的推送ID
#AppBody, #AuthBody, #successfulPush {
margin: 0 auto;
background-color: #ccc;
overflow: hidden;
overflow-y: auto;
}
common\index.html增加了一个额外的DIV:
<div id="successfulPush" style="display:none">
<div class="wrapper">
<h2>Notification received</h2>
<button id="back" >back to application</button>
<p id="pushContents"></p>
</div>
</div>
最终结果收到推送后,点击通知栏中的通知,应用程序将打开,您将看到successfulPush DIV。在那里,您有一个按钮可以返回到AppBody DIV。工作正常 如前所述,这只是一种可能的方法。你想做什么就做什么…
我认为一旦收到通知,会立即调用此函数吗?但是我只想在用户点击通知时打开一个新页面。我已经尝试过了,但在点击通知时它不会调用该功能。我会再试一次。谢谢。@AWSSET,这很好用。请参阅我的更新答案,了解一个小示例。嗨。很抱歉迟了答复。我使用了invoke adapter过程,最终收到了由pushnotificationReceived函数触发的警报,但是,我没有收到推送通知本身。我触发了大约15次,只收到1次推送通知。你在说什么。如果您收到通知,这意味着您已收到通知!警报是收到通知的结果。你问的问题措辞拙劣,我再也帮不了你了。
function pushNotificationReceived(props, payload) {
$("#AppBody").hide();
$("#successfulPush").show();
$("#pushContents").html(
"<b>Notification contents:</b><br>" +
"<b>Payload:</b> " + JSON.stringify(payload) + "<br>" +
"<b>Props:</b> " + JSON.stringify(props)
);
}
$("#back").bind("click", function() {
$("#successfulPush").hide();
$("#AppBody").show();
});