33

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)
Praveen Kumar
  • 1,338
  • 3
  • 20
  • 31
  • 1
    Sorry I just found the answer here. http://stackoverflow.com/questions/37956482/registering-for-push-notifications-in-xcode-8-swift-3-0 – Praveen Kumar Sep 28 '16 at 09:20

1 Answers1

70

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.

Alex Stone
  • 46,408
  • 55
  • 231
  • 407
Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100