在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]; }
- 当应用程序是后台收到的远程通知不打“didReceiveRemoteNotification – fetchCompletionHandler”方法,如果应用程序被杀害?
- 如果应用程序已经在后台运行,当用户点击通知时,如何获得推送通知的有效载荷?
- 苹果推送通知没有苹果服务器
- 允许连接到APNS的持续连接数量是多less?
- PushKit:我们可以在聊天应用程序中使用推送套件(VoiP Push),而不使用VoiP
- 无法接收来自Firebase 3.2.0主题的iOS推送通知
- iOS在应用程序内注册推送通知
- APNS错误响应包中不同状态代码的含义
- 如何使用Parse IOS SDK和来自Rails后端的REST推送通知