4

我正在尝试使用 Malcom API 在推送通知中发送自定义参数,但我无法从我的 iOS 应用程序中读取它们。

卷曲示例:

curl -u user:pass -H "Content-Type: application/json" -X POST -d '{ "notification": { "applicationCode": "appUDID", "environment": "SANDBOX", "message": "Message", "udids": [ "00c93096526860d932ba1bf116e752b8f2689675" ], "notificationCustomization": { "customfield": [ {"entry": { "key":"new_id", "value": "25" }} ], "badge": 5 } } }' http://api.mymalcom.com/v3/notification/push

iOS 代码(AppDelegate):

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

    [MalcomLib didReceiveRemoteNotification:userInfo active:[MalcomLib getAppActive]];

}

userInfo 包含以下信息:

{
    aps =     {
        alert = "Message";
        badge = 5;
    };
    notificationId = 521726;
}

你知道我在哪里可以读取这些参数吗?

4

1 回答 1

4

我认为你的 JSON 不够好。它应该是这样的:

{
"notification":{
  "applicationCode":"yourApplicationCode",
  "environment":"SANDBOX",
  "message":"YourMessage",
  "notificationCustomization":{
     "customFields":{
        "entry":[
           {
              "key":"yourkey1",
              "value":"yourvalue1"
           },
           {
              "key":"yourkey2",
              "value":"yourvalue2"
           },
           {
              "key":"yourkey3",
              "value":"yourvalue3"
           }
        ]
     }
  }

} }

希望这可以帮助。

于 2013-04-24T14:58:48.470 回答