我正在尝试使用Malcom API在推送通知中发送自定义参数,但我无法从iOS应用程序中读取它们。
示例CURL:
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;
}
你知道我在哪里可以阅读这些参数吗?
答案 0 :(得分:4)
我认为你的JSON不够好。它应该是这样的:
{
"notification":{
"applicationCode":"yourApplicationCode",
"environment":"SANDBOX",
"message":"YourMessage",
"notificationCustomization":{
"customFields":{
"entry":[
{
"key":"yourkey1",
"value":"yourvalue1"
},
{
"key":"yourkey2",
"value":"yourvalue2"
},
{
"key":"yourkey3",
"value":"yourvalue3"
}
]
}
}
} }
希望这有帮助。