在UIAlertView中显示推送通知的内容

您好我目前正在开发一个应用程序,我已经推动通知激活。 我使用parse.com。 我已经得到它的工作到目前为止,我可以发送通知,设备收到它,我也得到了应用程序的徽章。 我从通知中input应用程序时设置了一个AlertView。 但我不知道如何在UIAlertView中显示推送通知的文本。 而且我也希望徽章在您查看邮件时消失。 这里是代码Im使用:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if (application.applicationState == UIApplicationStateInactive) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [alert show]; } else if (application.applicationState == UIApplicationStateActive) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [alert show]; } } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { { NSDictionary * pushDictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (pushDictionary) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [alert show]; } } 

要处理推送通知,并显示警报视图及其信息,请在appDelegate中尝试:

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [PFPush handlePush:userInfo]; }