Created
September 25, 2019 16:40
-
-
Save bryanjclark/1804eda35750f676b6755dd8b559ddeb to your computer and use it in GitHub Desktop.
Provisional notifications in iOS
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
/// Sets up provisional authorization (as in, "trial notifications") | |
// see: https://asciiwwdc.com/2018/sessions/710 | |
fileprivate func requestProvisionalAuthorization() { | |
if #available(iOS 12.0, *) { | |
let options: UNAuthorizationOptions = [.provisional] | |
UNUserNotificationCenter.current().requestAuthorization(options: options) { (authorized, error) in | |
if let error = error { | |
logger.error(String(describing: error)) | |
} | |
} | |
} else { | |
logger.info("Not on iOS 12; can't schedule provisional notifications.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment