Last active
July 17, 2020 07:27
-
-
Save olivaresf/b57d9b1545e7e85e821a3febc8536f74 to your computer and use it in GitHub Desktop.
Example July 17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func requestAuthorization(completion: ((Bool, Error?) -> Void)? = nil) { | |
// enable local notifications (alarms in background) | |
let authorizationOptions: UNAuthorizationOptions | |
if #available(iOS 12.0, *) { | |
authorizationOptions = [.badge, .alert, .sound, .criticalAlert] | |
} else { | |
authorizationOptions = [.badge, .alert, .sound] | |
} | |
UNUserNotificationCenter.current().requestAuthorization(options: authorizationOptions) { (granted, error) in | |
// Enable or disable features based on authorization. | |
dispatchOnMain { | |
completion?(granted, error) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment