简体   繁体   English

从Bluemix推送通知获取URL标记值

[英]Getting url tag value from Bluemix push notification

I need to pass the url along with the notification message using Bluemix Rest API. 我需要使用Bluemix Rest API将URL与通知消息一起传递。 According to the docs 根据文档

{"message": {
"alert": "Notification alert message","url":"test.test.com" }}

The above rest call should send the message and the url. 上面的rest调用应该发送消息和url。 But when i tried to parse the Json object from the notification there is no tag that sends the url. 但是,当我尝试从通知中解析Json对象时,没有发送URL的标签。

在此处输入图片说明

 MFPPush.registerDevice(settings, success, failure);
 var notification = function(notif){
     alert (JSON.stringify(notif));

 };
 MFPPush.registerNotificationsCallback(notification);
    }}

The above is the code that I am registering the notification from javascript using Cordova app. 上面的代码是我使用Cordova应用程序从javascript注册通知的代码。

The code below shows the AppDelegate code on iOS: 以下代码显示了iOS上的AppDelegate代码:

-(void)application:(UIApplication *)application

didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void(^)(UIBackgroundFetchResult))completionHandler {

[[CDVMFPPush sharedInstance] didReceiveRemoteNotification:userInfo];

} }

When i have put a log statement for userInfo in AppDelegate, the following log is displayed: 当我在AppDelegate中放置了userInfo的日志语句时,将显示以下日志:

{
    aps =     {
        alert =         {
            "action-loc-key" = "<null>";
            body = test;
        };
    };
    payload = "{\"nid\":\"5a379af\",\"tag\":\"Push.ALL\"}";
    url = URL;
}

Its getting displayed in the dictionary. 它越来越显示在字典中。 But how to get the url value from it? 但是如何从中获取url值呢?

@Rahul,您必须在func didReceiveRemoteNotification(notification: NSDictionary?) {}方法内添加notif["url"] = notification?.valueForKey("url") func didReceiveRemoteNotification(notification: NSDictionary?) {}方法以显示在通知弹出窗口中。

Open the app in Xcode and go to CDVMFPPush.swift file and locate the func didReceiveRemoteNotification(notification: NSDictionary?) 在Xcode中打开应用程序,然后转到CDVMFPPush.swift文件,然后找到func didReceiveRemoteNotification(notification: NSDictionary?) CDVMFPPush.swift func didReceiveRemoteNotification(notification: NSDictionary?)

Add the following line inside the above function 在上面的函数中添加以下行

notif["url"] = notification?.valueForKey("url")

Hope this will help you. 希望这会帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Bluemix进行离子应用程序的推送通知 - Push Notification for Ionic Application Using Bluemix 我正在开发cordova Bluemix推送通知应用程序。 从Bluemix仪表板创建时,我找不到“ applicationSecret” - I'm developing a cordova Bluemix push notification application. I'm not able to find “applicationSecret” when I create from the Bluemix dashboard 推送通知未在移动应用上显示 - Push notification not getting on mobile app 通过推送通知触发操作 - Trigger Action from Push Notification android手机间隙中的推送通知未收到通知 - android push notification in phone gap not getting notifications 通过GCM推送通知获取错误的数据 - Getting wrong data throug GCM push notification 离子 Android 推送通知在 phonegap-plugin-push 上出错 - Ionic Android Push Notification getting error on phonegap-plugin-push Cordova通过Push Notification检测冷启动 - Cordova detect cold start from Push Notification 创建本地通知以响应cordova / ionic中的推送通知(来自firebase) - Creating a local notification in response to a push notification (from firebase) in cordova/ionic 推送通知 WP8.1“无效的频道 URL” - Push notification WP8.1 "Invalid channel URL"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM