【发布时间】:2015-03-21 04:23:50
【问题描述】:
我注意到,当我从通知中心为我的应用选择推送通知时,该通知不再出现在通知列表中。但是,当我收到通知并立即点击横幅时,应用程序会正常打开,但是当我下拉查看通知中心时,该通知仍然存在。我的委托中有以下推送处理代码:
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
[[UIApplication sharedApplication] cancelAllLocalNotifications];
//Presenting view controllers...
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Extract the notification data
NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if(notificationPayload)
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
return YES;
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
application.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
// when you tap on any of notification this delegate method will call...
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[[UIApplication sharedApplication] cancelLocalNotification:notification];
}
【问题讨论】:
标签: ios objective-c iphone notifications push-notification