Since iOS9, local notification aren't working properly. Sometimes users receive the notification, sometimes they just don't. My notifications are repeated daily. Any idea what might causing the issue? I saw some posts, that there's a bug in iOS9, but I'm not sure that's the reason.
Here's a piece of code:
NSDate *alarmDate = [date dateByAddingTimeInterval:DEFAULT_SNOOZE_DURATION * i];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = alarmDate;
localNotif.timeZone = nil;
localNotif.alertBody = alertBody;
localNotif.hasAction = YES;
localNotif.applicationIconBadgeNumber = 1;
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.repeatInterval = NSCalendarUnitDay;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif]
Thanks for your help
Include the below code in Appdelegate.m
write below code in AppDelegate.m
}
also write this code in AppDeleagte.m
write below code in your ViewController, where you wants to implement your local notification.
forExample : Here I initialise UILocalNotification, and Its Firedate is currentTime and 5seconds Interval Time.
After Fire localNotification it will give alert on Your Screen.
if You need it for iOS9 but under swift 3.1:
on iOS10 is deprecated.
From the Local and Remote Notification Programming Guide:
As shown in the guide, the sample code that Apple shows is:
https://stackoverflow.com/a/27376475/6219830 by : Naughty_Ottsel
This is my code:
I hope that help!