-
-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Summary
Add push notifications for Web, Android and desktop versions
Motivation
Currently we have only a Background Fetch implementation of Push Notifications adamant-im/src/lib/notifications.js at dev · Adamant-im/adamant-im.
How it works:
- In the background, we monitor new messages via REST or WebSocket and display a local push notification
- Push notifications work only if the app is running or minimized in the background
We must implement Push Notifications via Push service to be able to receive notifications when the app is not running. Also we must keep the Background Fetch option (like in the iOS app).
Detailed description
PWA
To integrate Push Notifications in the Web app we will use firebase. Check the FCM docs: Get started with Firebase Cloud Messaging
Android
There is a Capacitor plugin @capacitor/push-notifications for integration with FCM. See the guide: Push Notifications - Firebase | Capacitor Documentation
Implementation
Both PWA and Android must implement the following:
- Initialization with Firebase project
- Retrieve a device token from FCM
- Create and sign a Signal Message transaction for:
- Register new device: GitHub - Adamant-im/adamant-ns: ADAMANT Universal Push Notification Service
- Unregister device: GitHub - Adamant-im/adamant-ns: ADAMANT Universal Push Notification Service
- Decrypt the message before showing the notification:
- For Web: Is it possible? Maybe via ServiceWorker
- For Android: Probably possible (at least in iOS it works)
- The pushes must work in both Foreground and Background modes (Capacitor/Ionic: Handling push notification in background or when app was killed )
- Don’t display pushes if the app is opened
Ideally you must create an interface to unify the functionality of both platforms:
interface PushService {
platform: 'android' | 'web'
// Firebase project initialization
initialize(): void
// Request push notification permissions
registerNotifications(): void
// Subscribe to device token updates and push notifications
subscribe(event: 'pushNotificationReceived' | 'deviceToken', callback: (data: any) => void): void
}
💡 Tip: Use Capacitor.getPlatform() to detect the current platform: Capacitor's JavaScript API | Capacitor Documentation
UI
- On the Settings page add “Push Service“ option. Keep the old implementation as “Background Fetch“
- When the user enables the Push Notifications option you must request notification permissions
-
After permissions are granted, request the token from FCM and send a Signal Message to the ANS
-
In background: If the device token was updated, you must send the new token to ANS
-
If the user disables the Push Notifications you must notify the ANS to remove the token
-
Open a specific chat when clicking on push notification
Links
- Old notification service: GitHub - Adamant-im/adamant-notificationService: ADAMANT push Notification Service for iOS Messenger app
- New notification service: GitHub - Adamant-im/adamant-ns: ADAMANT Universal Push Notification Service
- AIP 6: Signal Messages: Signal Messages
Proposed technical implementation
See "Detailed description".
Metadata
Metadata
Assignees
Labels
Type
Projects
Status

