Step 1: Enable Push notifications

- Login to CometChat dashboard and select your app.
- Navigate to Notifications > Settings in the left-hand menu.
- Enable the Push notifications feature.
- Continue to configure Push notifications.
Step 2: Add Providers
Firebase Cloud Messaging (FCM) and Apple Push Notification Service (APNS) are the two primary supported providers for sending push notifications.Add FCM credentials
Pre-requisite
Generate a service account key for your Firebase application by navigating to the “Service accounts” section within the “Project settings” of the Firebase Cloud Messaging Dashboard. Generate new private key and download the JSON file. This will be required in the next steps.
Add credentials
- Select the ”+ Add Credentials” button.
- In the dialogue that appears, provide a unique, memorable identifier for your provider.
- Upload the service account JSON file you previously acquired.
- Specify whether the push payload should include the “notification” key. Additional information on this configuration is available in FCM’s documentation - About FCM messages.

Add APNS credentials
Pre-requisite
- To generate a .p8 key file, go to Apple Developer Account, then select “Certificates, IDs & Profiles”.
- Select Keys and click on the ”+” button to add a new key.
- In the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click “Continue” and click “Register”.
- Then proceed to download the key file by clicking Download.
- Make note of the Key ID, Team ID and your Bundle ID. These are required in the next steps.
Add credentials
- Select the ”+ Add Credentials” button.
- Enable the toggle if your app is in the Production. For apps under development, the toggle has to be disabled.
- In the dialogue that appears, provide a unique, memorable identifier for your provider.
- Store the Key ID, Team ID, Bundle ID for your app.
- Upload the .p8 file
- Enable “Include content-available” if you want to receive background notifications. However, this is not recommended as the background notifications are throttled. Additional information is available in Apple’s documentation - Pushing background updates to your App
- Enable “Include mutable-content” if you want to modify the notification before it is displayed to the user. Additional information is available in Apple’s documentation - Modifying content on newly delivered notifications

Custom providers
For webhook-based providers and payload samples, see Custom Providers.Step 3: Tokens management
Register push token after login
Push tokens, obtained from the APIs or SDKs provided by the platforms or frameworks in use, must be registered on behalf of the logged in user with the CometChat backend. For this purpose, CometChat SDKs v4+ offer the following functions: Push token registration should be completed in two scenarios:- Following the success of
CometChat.login()& receiving user’s permission to receiver Push notifications. - When a refresh token becomes available.
CometChatNotifications.registerPushToken() method from the SDK. This method accepts the following parameters.
| Parameter | Type | Description |
|---|---|---|
pushToken | String | The pushToken can contain:• Firebase (FCM) token • Device token (iOS only) • VoIP token (iOS only) |
platform | String | The platform can take the following values:• PushPlatforms.FCM_ANDROID • PushPlatforms.FCM_FLUTTER_ANDROID • PushPlatforms.FCM_FLUTTER_iOS • PushPlatforms.APNS_FLUTTER_DEVICE • PushPlatforms.APNS_FLUTTER_VOIP • PushPlatforms.FCM_iOS • PushPlatforms.APNS_iOS_DEVICE • PushPlatforms.APNS_iOS_VOIP • PushPlatforms.FCM_WEB • PushPlatforms.FCM_REACT_NATIVE_ANDROID • PushPlatforms.FCM_REACT_NATIVE_iOS • PushPlatforms.APNS_REACT_NATIVE_DEVICE • PushPlatforms.APNS_REACT_NATIVE_VOIP • PushPlatforms.FCM_IONIC_CORDOVA_ANDROID • PushPlatforms.FCM_IONIC_CORDOVA_iOS • PushPlatforms.APNS_IONIC_CORDOVA_DEVICE • PushPlatforms.APNS_IONIC_CORDOVA_VOIP |
providerId | String | The providerId should match with:• Any one of the FCM provider identifiers in case of an FCM token. • Any one of the APNS provider identifiers in case of Device or VoIP tokens. |
- JavaScript
- Android
- iOS
- Flutter
Unregister push token before logout
Typically, push token unregistration should occur prior to user logout, using theCometChat.logout() method.
For token unregistration, use the CometChatNotifications.unregisterPushToken() method provided by the SDKs.
- JavaScript
- Android
- iOS
- Flutter
Step 4: Handle incoming Push notifications
Push notifications should be managed primarily when the app is in the background or in a terminated state. For web and mobile applications, the Firebase Cloud Messaging (FCM) SDK offers handler functions to receive Push Notifications. For iOS applications, the FCM SDK can be used as described previously, or alternatively, PushKit can be implemented for better integration and management of chat and call (VoIP) notifications. The push payload delivered to the user’s device includes the following information, which can be customized to suit the desired notification style:- Details available in the payload