2013-12-19 99 views
1

我知道UINotification何时关闭,当用户不通过触摸通知本身启动应用程序,而是通过快速应用程序切换或主屏幕图标时,知道UINotification是否已关闭。当applicationDidBecomeActive

我检查了[[UIApplication sharedApplication] scheduledLocalNotifications]但在通知发布后,此数组为空。

回答

1

一旦localnotification是通知中心将显示的火灾,它将不会显示在[[UIApplication sharedApplication] scheduledLocalNotifications]

如果您的应用处于活动状态,将会调用didreceivelocalnotification,但是当您的应用未处于活动状态时,它将显示在通知中心。

所以它会留在通知中心,直到你清除它。

如果你想得到你可以检查它在appdelegate方法与didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法。

UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
    if (localNotif) 
    { 
     NSLog(@"lcoal:%@",[localNotif userInfo]); 
     UIAlertView *al=[[UIAlertView alloc]initWithTitle:@"Challenge gehaald!" message:@"Gefeliciteerd, je hebt deze bonus challenge succesvol afgerond." delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
     [al show]; 
    } 
相关问题