Add Local Notification in iOS 10 – Swift 3

You need to register for Notification…I tried and this works. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. let center = UNUserNotificationCenter.current() center.requestAuthorization([.alert, .sound]) { (granted, error) in // Enable or disable features based on authorization. } return true } Edit: You dont need … Read more

iPhone: Incrementing the application badge through a local notification

I’ve found, implemented & tested a ‘workaround’ for (apparantly) auto-incrementing the app icon’s badge number, that works fine with non-repeating local notifications It is indeed not possible for UILocalNotifications to have iOS ‘automatically’ update/increment the badge number when multiple local notifications are fired, and the user ‘ignores’ them or doesn’t handle them immediately, so they … Read more

UILocalNotification Repeat Interval for Custom Alarm (sun, mon, tue, wed, thu, fri, sat)

You cannot set custom repeat intervals with UILocalNotification. This has been asked before (see below) but only limited options are provided. The repeatInterval parameter is an enum type and it limited to specific values. You cannot multiply those enumerations and get multiples of those intervals. You cannot have more than 64 local notifications set in … Read more

Getting local notifications to show while app is in foreground Swift 3

There is a delegate method to display the notification when the app is open in iOS 10. You have to implement this in order to get the rich notifications working when the app is open. extension ViewController: UNUserNotificationCenterDelegate { //for displaying notification when app is in foreground func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler … Read more

Displaying a stock iOS notification banner when your app is open and in the foreground?

iOS 10 adds the UNUserNotificationCenterDelegate protocol for handling notifications while your app is in the foreground. The UNUserNotificationCenterDelegate protocol defines methods for receiving notifications and for handling actions. When your app is in the foreground, arriving notifications are delivered to your delegate object instead of displayed automatically using the system interfaces. Swift: optional func userNotificationCenter(_ … Read more

Delete a particular local notification

You can save a unique value for key in your local notification’s userinfo. Get all local notification, loop through the array and delete the particular notification. Code as follows, OBJ-C: UIApplication *app = [UIApplication sharedApplication]; NSArray *eventArray = [app scheduledLocalNotifications]; for (int i=0; i<[eventArray count]; i++) { UILocalNotification* oneEvent = [eventArray objectAtIndex:i]; NSDictionary *userInfoCurrent = … Read more