I have push notifications in my app. Whenever the app is launched, I would like to check whether the user has enabled push notification for my application.
I do it this
Here is the most thorough way, as of iOS12 and Swift 5:
_ = UNUserNotificationCenter.current().getNotificationSettings { (settings) in
switch settings.authorizationStatus {
case .notDetermined:
<#code#>
case .denied:
<#code#>
case .authorized:
<#code#>
case .provisional:
<#code#>
@unknown default:
<#fatalError()#>
}
}