notifications: initial setup

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-07-21 17:54:11 -07:00
parent b838849010
commit ce9551ce56
3 changed files with 30 additions and 0 deletions

View File

@@ -182,6 +182,7 @@ struct ContentView: View {
}
.onAppear() {
self.connect()
setup_notifications()
}
.sheet(item: $active_sheet) { item in
switch item {
@@ -479,3 +480,20 @@ func update_filters_with_since(last_of_kind: [Int: NostrEvent], filters: [NostrF
}
}
func setup_notifications() {
UIApplication.shared.registerForRemoteNotifications()
let center = UNUserNotificationCenter.current()
center.getNotificationSettings { settings in
guard settings.authorizationStatus == .authorized else {
center.requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
}
return
}
}
}