Last active
December 14, 2021 03:50
-
-
Save hanfengs/32df9fa022eaa2a927de6fc1f18937b9 to your computer and use it in GitHub Desktop.
[swift权限]
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
// https://juejin.cn/post/6844904142045970445#heading-2 | |
func notificationAuthorization() { | |
let camera = AVCaptureDevice.authorizationStatus(for: .video) | |
if camera == .notDetermined { | |
return | |
} | |
let location = CLLocationManager.authorizationStatus() | |
if location == .notDetermined { | |
return | |
} | |
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound]) { (granted, _) in | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment