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.

Share:
29,364
Praveen Kumar
Author by

Praveen Kumar

Updated on April 23, 2020

Comments

  • Praveen Kumar
    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
    Bhavin_m over 6 years
    Do not forget to application.registerForRemoteNotifications() below this code.
  • Gabriel Garrett
    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
    NickDK over 6 years
    Also don't forget to link with UserNotifications.framework and @import UserNotifications.
  • Fattie
    Fattie about 4 years
    great tip to link with link with UserNotifications.framework !!