[英]iOS Push Notifications Message
I want to display a push notifications message in an AlertView. 我想在AlertView中显示推送通知消息。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSDictionary *dic = [userInfo objectForKey:@"aps"];
NSString *message = [userInfo objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Sie haben eine eine Nachricht." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
That's what userInfo
variable contains: 这就是userInfo
变量包含的内容:
I have tried this but *message
is nil
. 我试过这个,但*message
是nil
。
NSString *message = [userInfo objectForKey:@"alert"];
How can I get the "alert"
value? 如何获得"alert"
值? Any ideas?. 有任何想法吗?。
Thanks in advance. 提前致谢。
This is probably what you needed: 这可能是你需要的:
NSDictionary *dic = [userInfo objectForKey:@"aps"];
NSString *message = [dic objectForKey:@"alert"];
Using modern syntax, this should get you what you want. 使用现代语法,这应该可以得到你想要的。 The 'alert' value is inside the 'aps' dictionary. 'alert'值在'aps'字典中。
NSString *message = userInfo[@"aps"][@"alert"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.