用户单击MobileFirst应用程序中的通知中心消息后执行某些操作?

时间:2015-09-03 14:48:52

标签: ibm-mobilefirst

页面导航并与后端系统通信应在用户点击进入应用程序的通知中心消息后进行。

但我的代码应该在哪里?

1 个答案:

答案 0 :(得分:0)

在处理传入通知的同一函数中。

如果您使用基于事件源的通知,那么这将是pushNotificationReceived()功能。用所需的应用逻辑替换警报。

function pushNotificationReceived(props, payload) {
    alert("pushNotificationReceived invoked");
    alert("props :: " + JSON.stringify(props));
    alert("payload :: " + JSON.stringify(payload));
}

如果您正在使用广播/标记通知,则会以类似的方式完成。从示例应用程序中,您可以执行以下操作,只需替换为您所需的应用程序逻辑:

WL.Client.Push.onMessage = function (props, payload) {
    WL.SimpleDialog.show("Tag Notifications", "Provider notification data: " + JSON.stringify(props), [ {
        text : 'Close',
        handler : function() {
            WL.SimpleDialog.show("Tag Notifications", "Application notification data: " + JSON.stringify(payload), [ {
                text : 'Close',
                handler : function() {}
              }]);      
        }
    }]);
};