【发布时间】:2016-04-11 12:20:17
【问题描述】:
我从我的服务器推送通知中得到这个,这是 NSDictionary 格式的。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler {
NSLog(@"Recieved remote notification %@", userInfo);
}
{
aps = {
alert = "{\n \"GCM\":{\n \"data\":{\n \"notificationType\":\"order\",\n \"oid\":\"CRN14333313\",\n \"c\":\"allocated\",\n \"f\":\"253.633333333333\" }\n }\n }";
};
}
我正在尝试将其转换为没有任何“\”或“\n”的普通 NSDictionary。我该怎么做?
这种 NSDictionary 格式的预期结果
{
aps = {
alert = "{
"GCM"={
"data"={
"notificationType"="ons",
"oid"="N14333313",
"c"="allocated",
"f"="253.633333333333",
}
}
}";
};
}
【问题讨论】:
-
你打印这个
NSLog(@"Recieved remote notification %@", userInfo);的回复一次 -
是的,我正在这样做
-
请原谅......
-
那么您在
alert字段中收到了一个JSON?那看起来不太好。查看您发送的 APNS JSON 有效负载。
标签: ios objective-c json nsdictionary