2014-09-22 28 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 
} 
相关问题