Skip to content

[Feat, Enhancement] Push notifications for Web/Android, Desktop #881

@Linhead

Description

@Linhead

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).

Image Image

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:

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“
Image
  • When the user enables the Push Notifications option you must request notification permissions ​
Image
  • 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

Proposed technical implementation

See "Detailed description".

Metadata

Metadata

Assignees

Labels

APIsAPI design, endpoints, and integrationsComposite taskLarge or complex task that consists of multiple subtaskMessagingMessengers, communication protocols, news, mentionsPrimary featureKey feature essential for product functionalityTypeScriptCode and typing improvements in TypeScriptUX/UIUser interface and experience improvementsVueFrontend features or fixes primarily in Vue.jsenhancementNew feature or request

Projects

Status

In Review

Relationships

None yet

Development

No branches or pull requests

Issue actions