UIUserNotificationSettings deprecated in iOS 10
29,364
Registration of notification you should implement this code :
import UserNotifications
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
(granted, error) in
//Parse errors and track state
}
This resource contains additional information.
Author by
Praveen Kumar
Updated on April 23, 2020Comments
-
Praveen Kumar about 4 years
I am looking for the alternate way of implementing UIUserNotificationSettings in iOS 10.
Apple documentation has given the below framework for the further usage. UNNotificationSettings in the link here.
Is there any one who can help me with the sample code to implement the below using the UNNotificationSettings instead of UIUserNotificationSettings
let notificationSettings = UIUserNotificationSettings( forTypes: [.Badge, .Sound, .Alert], categories: nil) application.registerUserNotificationSettings(notificationSettings)
-
Bhavin_m over 6 yearsDo not forget to
application.registerForRemoteNotifications()
below this code. -
Gabriel Garrett over 6 years@iOS.Wolf this is only necessary if you plan on having push notifications that aren't just local notifications.
-
NickDK over 6 yearsAlso don't forget to link with UserNotifications.framework and @import UserNotifications.
-
Fattie about 4 yearsgreat tip to link with link with UserNotifications.framework !!