Add experimental push notification support

I added support for the experimental push notifications feature. There are many improvements to be made, so this feature is currently opt-in only. If the user does not opt-in, their device tokens will not be sent out and thus they will receive no push notifications.

We should perform more testing on real-life staging environments before fully releasing this feature.

Testing
-------

Testing was done gradually during development.

Device: iOS simulators
iOS: 17
Damus version: A few different but recent prototypes
Rough coverage:
1. Checked that no device tokens are sent out when setting is off
2. Checked that I can successfully receive device tokens when feature is ON and set to localhost.
3. Checked sending test push notifications of types "note" (kind: 1), reaction (kind: 7) and DMs (kind 4) works and shows a generic but reasonable push notification message
4. Checked that clicking on the notifications above take the user to the correct screen

Closes: https://github.com/damus-io/damus/issues/67
Changelog-Added: Add experimental push notification support
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Daniel D’Aquino
2023-11-14 07:21:39 +00:00
committed by William Casarin
parent 878b1caa95
commit ad75d8546c
13 changed files with 562 additions and 5 deletions
+3 -1
View File
@@ -54,6 +54,7 @@ enum Sheets: Identifiable {
struct ContentView: View {
let keypair: Keypair
let appDelegate: AppDelegate?
var pubkey: Pubkey {
return keypair.pubkey
@@ -303,6 +304,7 @@ struct ContentView: View {
active_sheet = .onboardingSuggestions
hasSeenOnboardingSuggestions = true
}
self.appDelegate?.settings = damus_state?.settings
}
.sheet(item: $active_sheet) { item in
switch item {
@@ -694,7 +696,7 @@ struct ContentView: View {
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView(keypair: Keypair(pubkey: test_pubkey, privkey: nil))
ContentView(keypair: Keypair(pubkey: test_pubkey, privkey: nil), appDelegate: nil)
}
}