mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
20 lines
630 B
Swift
20 lines
630 B
Swift
|
|
import Foundation
|
||
|
|
import UserNotifications
|
||
|
|
|
||
|
|
public extension UNUserNotificationCenter {
|
||
|
|
/// Shows prompt to user to allow push notifications
|
||
|
|
/// If previously denied then no prompt is shown
|
||
|
|
func requestAuth() {
|
||
|
|
// Only the first call to this function will result in a prompt
|
||
|
|
// If user denies the first time then that gets saved to device settings
|
||
|
|
requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
|
||
|
|
guard error != nil else { return }
|
||
|
|
|
||
|
|
if !granted {
|
||
|
|
// Maybe show instructions to change in settings?
|
||
|
|
print("user denied push notifications")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|