Skip to content

Instantly share code, notes, and snippets.

@hanfengs
Last active December 14, 2021 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanfengs/32df9fa022eaa2a927de6fc1f18937b9 to your computer and use it in GitHub Desktop.
Save hanfengs/32df9fa022eaa2a927de6fc1f18937b9 to your computer and use it in GitHub Desktop.
[swift权限]
// 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