Tutorial by Examples

Make sure you see Registering for local notifications in order for this to work: Swift let notification = UILocalNotification() notification.alertBody = "Hello, local notifications!" notification.fireDate = NSDate().dateByAddingTimeInterval(10) // 10 seconds after now UIApplication.sh...
iOS 8 In order to present local notifications to the user, you have to register your app with the device: Swift let settings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil) UIApplication.sharedApplication().registerUserNotificationSettings(settings) Objective...
IMPORTANT: This delegate method is only called in the foreground. Swift func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) { } Objective-C - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotifi...
Often times you will need to be able to manage your notifications, by being able to keep track of them and cancel them. Track a notification You can assign a UUID (universally unique identifier) to a notification, so you can track it: Swift let notification = UILocalNotification() let uuid = NS...
If you want to show local notification immediately, you should call: Swift 3 UIApplication.shared.presentLocalNotificationNow(notification) Swift 2 UIApplication.sharedApplication().presentLocalNotificationNow(notification) Objective-C [[UIApplication sharedApplication] presentLocalNotific...
Custom sounds may be provided for notifications generated by your app. When the system displays an alert for a local notification or badges an app icon, it plays this sound (so long as the user has not disabled notification sounds). The default value is nil which means no sound is played for your n...
Registration in AppDelegate import UserNotifications in didFinishLaunchingWithOptions method, UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.sound,.badge]) { (granted, error) in // Here you can check Request is Granted or not. } Create and Schedule notificat...
You can use UILocalNotification, old APIs also works fine with iOS10, but we had better use the APIs in the User Notifications framework instead. There are also some new features, you can only use with iOS10 User Notifications framework. This also happens to Remote Notification, for more informatio...

Page 1 of 1