2013-12-19 51 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]; 
    } 
相關問題