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
}
}
}

8
damus/damus.entitlements Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>