Scheduled performance LocalNotification (large number of local notifications)

Possible duplicate:
Local Notification Schedule Number

I ran into a performance issue with schedLocalNotification. I am trying to register a large number of local notifications. It’s like money reminders for friends. For the test, I tried to register about 300 notifications, but my iPhone4 took more than 2 minutes. (iPad2 4 seconds, iPhone4S 8 seconds)

Here is the code.

-(void)setAllBirthdaysSchedule { Class cls = NSClassFromString(@"UILocalNotification"); if (cls == nil) { return ; } NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [[UIApplication sharedApplication] cancelAllLocalNotifications]; if (prototypeNotification == nil) { prototypeNotification = [[UILocalNotification alloc] init]; prototypeNotification.repeatCalendar = [NSCalendar currentCalendar]; prototypeNotification.repeatInterval = NSYearCalendarUnit; prototypeNotification.timeZone = [NSTimeZone defaultTimeZone]; prototypeNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:0]; prototypeNotification.applicationIconBadgeNumber = 0; prototypeNotification.alertBody = NSLocalizedString(@"Body", nil); prototypeNotification.alertAction = NSLocalizedString(@"Action", nil); } NSArray* arr = [self getAllBirthday]; for (User* user in arr) { UILocalNotification *notif = [prototypeNotification copy]; notif.fireDate = user.birthday; [[UIApplication sharedApplication] scheduleLocalNotification:notif]; [notif release]; } [pool release]; } 
+4
source share
1 answer

Yes, on older devices, it took some time to register a local notification. Try putting registration in the background thread.

Please note that in iOS there are no more than 64 notifications, the rest will be discarded. See the UILocalNotification class for more details.

+1
source

Source: https://habr.com/ru/post/1438588/


All Articles