How to delete all local notifications when an application is deleted from an iPhone

As others have mentioned, I think the best way to accomplish this is to have a flag in didFinishLaunchingWithOptions in the application delegate that checks if it is the first launch or not. If the app is being launched for the first time, you can call [[UIApplication sharedApplication] cancelAllLocalNotifications]; This will cancel any existing notifications. … Read more

Set default iOS local notification style for application

I would like to add something, since I’ve opened a TSI and somehow I asked about this and have been answered. From Quinn “The Eskimo!”: “This depends on you mean. You have some control over how the notification appears based on how you set the UILocalNotification properties (things like alertBody, soundName, and so on). However, … Read more

Triggering a specific action when the app enters foreground from a local notification in iOS? (using swift)

If I want a view controller to be notified when the app is brought back to the foreground, I might just register for the UIApplication.willEnterForegroundNotification notification (bypassing the app delegate method entirely): class ViewController: UIViewController { private var observer: NSObjectProtocol? override func viewDidLoad() { super.viewDidLoad() observer = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: .main) { [unowned … Read more

detect “Allow Notifications” is on/off for iOS8

Method enabledRemoteNotificationTypes is deprecated since iOS8. To check remote notifications status in iOS8 you can call [[UIApplication sharedApplication] isRegisteredForRemoteNotifications]; it will return NO if user disable notifications in Settings. Documentation on isRegisteredForRemoteNotifications Or you can retrieve all current notification settings: [[UIApplication sharedApplication] currentUserNotificationSettings]; Documentation on currentUserNotificationSettings

Test if app did become active from a UILocalNotification

I got the clue to the solution for this from @naveed’s tip on checking the state of the application when the didReceiveNotification method is called. No need to check variables etc when the app resumes from the background. On iOS7 and lower you handle the notifications like this: – (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { if … 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