2014-09-22 30 views
0

在我的應用程序中,可能會出現一個場景,其中幾個本地通知將與非常接近的「火災日期」非常接近地發射。iOS >> UILocalNotification迷失

如果應用程序在前臺,AppDelegate似乎通過didReceiveLocalNotification方法捕獲它們。

但是...如果應用程序在後臺或關閉,我點擊主屏幕彈出的'彈出',這種方法只捕獲第一個通知,而其他人似乎丟失;我需要他們所有的...

任何人?

+0

你不能使用NSNotification的userInfo嗎? – 2014-09-22 09:50:03

回答

0

對於本地通知您是否在下面嘗試過?

NSArray *pendingNotifications = [[[UIApplication sharedApplication] scheduledLocalNotifications] sortedArrayUsingComparator:^(id obj1, id obj2) { 
     if ([obj1 isKindOfClass:[UILocalNotification class]] && [obj2 isKindOfClass:[UILocalNotification class]]) 
     { 
      UILocalNotification *notif1 = (UILocalNotification *)obj1; 
      UILocalNotification *notif2 = (UILocalNotification *)obj2; 
      return [notif1.fireDate compare:notif2.fireDate]; 
     } 

     return NSOrderedSame; 
    }]; 
// if there are any pending notifications -> adjust their badge number 
if (pendingNotifications.count != 0) 
{ 
    //do something 
} 
相關問題