【发布时间】:2014-03-12 22:02:44
【问题描述】:
您好,我目前正在开发一个应用程序,我已在其中激活了推送通知。我使用 parse.com。到目前为止,我已经让它工作了,我可以发送通知并且设备接收它,我还在应用程序上获得了一个徽章。当您从通知进入应用程序时,我已经设置了一个 AlertView。但我不知道如何在 UIAlertView 中显示推送通知的文本。我还希望在您查看消息时徽章消失。这是我使用的代码:
- (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];
}
}
【问题讨论】:
标签: ios push-notification uialertview