Bluemix Rest API を使用して、通知メッセージとともに URL を渡す必要があります。ドキュメントによると
{"message": {
"alert": "Notification alert message","url":"test.test.com" }}
上記の残りの呼び出しは、メッセージと URL を送信する必要があります。しかし、通知から Json オブジェクトを解析しようとすると、URL を送信するタグがありません。
MFPPush.registerDevice(settings, success, failure);
var notification = function(notif){
alert (JSON.stringify(notif));
};
MFPPush.registerNotificationsCallback(notification);
}}
上記は、Cordova アプリを使用して JavaScript からの通知を登録しているコードです。
以下のコードは、iOS の AppDelegate コードを示しています。
-(void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[[CDVMFPPush sharedInstance] didReceiveRemoteNotification:userInfo];
}
AppDelegate に userInfo のログ ステートメントを配置すると、次のログが表示されます。
{
aps = {
alert = {
"action-loc-key" = "<null>";
body = test;
};
};
payload = "{\"nid\":\"5a379af\",\"tag\":\"Push.ALL\"}";
url = URL;
}
辞書に表示されるようになりました。しかし、そこから url 値を取得する方法は?
