MXV MXV - 1 year ago 90
Swift Question

Swift: Action if the user accepted or rejected notifications

I'm using the following code to request push and local notification permission:

let application = UIApplication.shared
let settings: UIUserNotificationSettings = UIUserNotificationSettings( types: [.alert, .badge, .sound], categories: nil )

application.registerUserNotificationSettings( settings )

I need to wait for the user to either accept or decline the notifications before I take an action. How can I achieve this?

Answer Source

When the user has either granted or denied permissions, the callback method in the app delegate is application(_:didRegister:) which is the method you should use for taking specific actions based on the user's chosen permission settings. I suggest reading the documentation here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download