Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIUserNotificationSettings deprecated in iOS 10 [duplicate]

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)
like image 632
Praveen Kumar Avatar asked Sep 28 '16 09:09

Praveen Kumar


1 Answers

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.

like image 192
Oleg Gordiichuk Avatar answered Nov 18 '22 00:11

Oleg Gordiichuk