【发布时间】:2015-12-29 19:06:45
【问题描述】:
我正在使用 Parse.com 将推送通知发送到一个简单的 iOS Web 视图应用程序,但我似乎无法让它显示我的 JSON 有效负载中的消息文本:
{
"alert": "Push Message goes here.",
"url": "http://www.google.com"
}
这是我的AppDelegate.m:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSString* notifURL = [userInfo objectForKey:@"url"];
NSLog(@"Received Push Url: %@", notifURL);
NSString* message = [userInfo objectForKey:@"alert"];
NSLog(@"Received Message: %@", message);
NSLog(@"UserInfo: %@", userInfo);
if (application.applicationState == UIApplicationStateActive) {
UIAlertView *alertPush = [[UIAlertView alloc]initWithTitle:@"My Webview App"
message:message
delegate:self
cancelButtonTitle:@"View"
otherButtonTitles:@"Cancel", nil];
[alertPush show];
[alertPush release];
objc_setAssociatedObject(alertPush, &aURL, notifURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
}
这是我的日志返回的内容:
收到推送地址:http://www.google.com
收到的消息:(空)
用户信息:{ ap = { alert = "推送标题到这里"; }; 网址 = "http://www.google.com"; }
我错过了什么吗?
【问题讨论】:
-
请向我们展示
NSLog(@"UserInfo %@" userinfo);的输出 -
@AnoopVaidya 我已经用 UserInfo 输出更新了我的帖子,谢谢。
标签: ios objective-c json