2014-12-03 253 views
1

我想在AlertView中显示推送通知消息。iOS推送通知消息

- (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]; 
} 

这就是userInfo变量包含:

enter image description here

我都试过,但*messagenil

NSString *message = [userInfo objectForKey:@"alert"];

我怎样才能获得"alert"价值?有任何想法吗?。

在此先感谢。

回答

2

这可能是你需要的东西:

NSDictionary *dic = [userInfo objectForKey:@"aps"]; 
NSString *message = [dic objectForKey:@"alert"]; 
+0

buahh非常愚蠢的错误...谢谢,对不起我的愚蠢的问题.. – Ale 2014-12-03 12:11:58

+0

不用担心,这是很好的,你花写一个详细的描述的时候:) – user623396 2014-12-03 12:17:50

1

利用现代语法,这应该得到你想要的东西。 “提醒”值位于'aps'字典内。

NSString *message = userInfo[@"aps"][@"alert"]