Monday 19 September 2016

iOS Overview: How to Create Local Notifications in iOS10

iOS Overview: How to Create Local Notifications in iOS10:

From iOS10 and onwards Apple deprecated UILocalNotification . We need to use UNNotificationRequest instead. UNNotificationRequest is def...

How to Create Local Notifications in iOS10

From iOS10 and onwards Apple deprecated UILocalNotification. We need to use UNNotificationRequest instead.

UNNotificationRequest is defined under UserNotifications framework. UNNotificationRequest consists of the following two objects or properties.

(a) UNNotificationContent
It defines the contents on the notification. For local notifications, create a UNMutableNotificationContent object and configure the contents of that object instead.

(b) UNNotificationTrigger
This is for defining an event that triggers the delivery of the notification.

Before triggering a notification, the first step from the App we should do is requesting authorisation for user interactions. The first time your app requests authorization, the user is alerted and given an opportunity to deny or grant that authorization.


Requesting authorization for user interactions in Objective C




Requesting authorization for user interactions in Swift




Creating a simple local notification in Objective C




Creating a simple local notification in Swift




Once the notification is triggered and the application is in background , notification UI will pop up with a sound.