diff --git a/android/app/capacitor.build.gradle b/android/app/capacitor.build.gradle
index 60f2508d..b02acc84 100644
--- a/android/app/capacitor.build.gradle
+++ b/android/app/capacitor.build.gradle
@@ -12,6 +12,7 @@ dependencies {
implementation project(':capacitor-community-safe-area')
implementation project(':capacitor-app')
implementation project(':capacitor-keyboard')
+ implementation project(':capacitor-push-notifications')
implementation project(':nostr-signer-capacitor-plugin')
}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index ec92f268..65a9dbe7 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -34,4 +34,5 @@
+
diff --git a/android/capacitor.settings.gradle b/android/capacitor.settings.gradle
index 89572353..a9c2e179 100644
--- a/android/capacitor.settings.gradle
+++ b/android/capacitor.settings.gradle
@@ -11,5 +11,8 @@ project(':capacitor-app').projectDir = new File('../node_modules/.pnpm/@capacito
include ':capacitor-keyboard'
project(':capacitor-keyboard').projectDir = new File('../node_modules/.pnpm/@capacitor+keyboard@7.0.1_@capacitor+core@7.2.0/node_modules/@capacitor/keyboard/android')
+include ':capacitor-push-notifications'
+project(':capacitor-push-notifications').projectDir = new File('../node_modules/.pnpm/@capacitor+push-notifications@7.0.1_@capacitor+core@7.2.0/node_modules/@capacitor/push-notifications/android')
+
include ':nostr-signer-capacitor-plugin'
project(':nostr-signer-capacitor-plugin').projectDir = new File('../node_modules/.pnpm/nostr-signer-capacitor-plugin@0.0.4_@capacitor+core@7.2.0/node_modules/nostr-signer-capacitor-plugin/android')
diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift
index c3cd83b5..eac186ae 100644
--- a/ios/App/App/AppDelegate.swift
+++ b/ios/App/App/AppDelegate.swift
@@ -46,4 +46,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
}
+ func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
+ // Enable push notifications https://capacitorjs.com/docs/apis/push-notifications
+ NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
+ }
+
+ func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
+ // Enable push notifications https://capacitorjs.com/docs/apis/push-notifications
+ NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
+ }
}
diff --git a/ios/App/App/Info.plist b/ios/App/App/Info.plist
index e3674ac7..79214e9f 100644
--- a/ios/App/App/Info.plist
+++ b/ios/App/App/Info.plist
@@ -49,5 +49,9 @@
ITSAppUsesNonExemptEncryption
+ UIBackgroundModes
+
+ remote-notification
+
diff --git a/ios/App/Podfile b/ios/App/Podfile
index 397e79d9..737c8d89 100644
--- a/ios/App/Podfile
+++ b/ios/App/Podfile
@@ -14,6 +14,7 @@ def capacitor_pods
pod 'CapacitorCommunitySafeArea', :path => '../../node_modules/.pnpm/@capacitor-community+safe-area@7.0.0-alpha.1_@capacitor+core@7.2.0/node_modules/@capacitor-community/safe-area'
pod 'CapacitorApp', :path => '../../node_modules/.pnpm/@capacitor+app@7.0.1_@capacitor+core@7.2.0/node_modules/@capacitor/app'
pod 'CapacitorKeyboard', :path => '../../node_modules/.pnpm/@capacitor+keyboard@7.0.1_@capacitor+core@7.2.0/node_modules/@capacitor/keyboard'
+ pod 'CapacitorPushNotifications', :path => '../../node_modules/.pnpm/@capacitor+push-notifications@7.0.1_@capacitor+core@7.2.0/node_modules/@capacitor/push-notifications'
pod 'NostrSignerCapacitorPlugin', :path => '../../node_modules/.pnpm/nostr-signer-capacitor-plugin@0.0.4_@capacitor+core@7.2.0/node_modules/nostr-signer-capacitor-plugin'
end
diff --git a/package.json b/package.json
index 112dbac9..46fdae66 100644
--- a/package.json
+++ b/package.json
@@ -45,6 +45,7 @@
"@capacitor/core": "^7.0.1",
"@capacitor/ios": "^7.0.0",
"@capacitor/keyboard": "^7.0.0",
+ "@capacitor/push-notifications": "^7.0.1",
"@poppanator/sveltekit-svg": "^4.2.1",
"@sentry/browser": "^8.35.0",
"@sveltejs/adapter-static": "^3.0.4",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8f03d2da..17515a11 100644
Binary files a/pnpm-lock.yaml and b/pnpm-lock.yaml differ
diff --git a/src/app/commands.ts b/src/app/commands.ts
index b1e5298b..0f388d52 100644
--- a/src/app/commands.ts
+++ b/src/app/commands.ts
@@ -1,6 +1,5 @@
import * as nip19 from "nostr-tools/nip19"
import {get} from "svelte/store"
-import {Capacitor} from "@capacitor/core"
import {randomId, flatten, poll, uniq, equals, TIMEZONE, LOCALE} from "@welshman/lib"
import type {Feed} from "@welshman/feeds"
import type {TrustedEvent, EventContent} from "@welshman/util"
@@ -21,6 +20,7 @@ import {
ALERT_ANDROID,
isSignedEvent,
makeEvent,
+ getAddress,
displayProfile,
normalizeRelayUrl,
makeList,
@@ -62,8 +62,8 @@ import {
NOTIFIER_PUBKEY,
NOTIFIER_RELAY,
userRoomsByUrl,
+ deviceAlertAddresses,
} from "@app/state"
-import {getPushInfo} from "@app/push"
// Utils
@@ -388,10 +388,10 @@ export type AlertParams = {
auth: string
}
ios?: {
- nothing: string
+ device_token: string
}
android?: {
- nothing: string
+ device_token: string
}
}
@@ -433,5 +433,10 @@ export const makeAlert = async (params: AlertParams) => {
})
}
-export const publishAlert = async (params: AlertParams) =>
- publishThunk({event: await makeAlert(params), relays: [NOTIFIER_RELAY]})
+export const publishAlert = async (params: AlertParams) => {
+ const event = await signer.get().sign(await makeAlert(params))
+
+ deviceAlertAddresses.update($addresses => [...$addresses, getAddress(event)])
+
+ return publishThunk({event, relays: [NOTIFIER_RELAY]})
+}
diff --git a/src/app/components/AlertAdd.svelte b/src/app/components/AlertAdd.svelte
index 58d56df8..697d0256 100644
--- a/src/app/components/AlertAdd.svelte
+++ b/src/app/components/AlertAdd.svelte
@@ -1,18 +1,28 @@