Push Notification

To configure Firebase Push Notifications for CometChat create a firebase project at https://console.firebase.google.com/ and follow the steps below:

1. Click “Add Firebase to your Android app” or “Add another app” option.

2. Add the android package name, the application nickname and the SHA-1 details. Click on the Register App button once the details are entered. Click on ‘Download google-services.json’ button to get the google-services.json file’. Add the file to the root directory of your project. Add the dependencies as mentioned to the gradle files.

3. Go to Android app settings by clicking on “settings” option in more settings menu(Vertical dotted icon)

4. Get the “Web API Key” to configure firebase push notification service from CometChat Admin Panel.

5. Add the “Web API Key” as “Firebase server key” in CometChat Admin Panel under Settings -> Mobile tab

6. Refer https://firebase.google.com/docs/cloud-messaging/android/client to configure your mobile app to receive the push notifications.

7. You need to subscribe to a channel from where you will get the push notification. You will get this channel from the response received in gotProfileInfo() callback when you call the subscribe method using the SDK.The response of callbacks contains a key named as “push_channel”. This contains the push notification channel. Once you subscribe to this channel, you will start receiving push notifications for a one-on-one chat.

8. For push notifications in a group,you will get “push_channel” from the response received in success callback of the joinGroup method. Once you subscribe to this channel, you will start receiving push notifications for the group.

9. For push notifications in Announcement, you will get “push_an_channel” in the response of gotProfileInfo() callback when you call the subscribe method using the SDK. In the response, you will receive a key named ‘push_an_channel’. Once you subscribe to this channel you will start receiving a push notification for announcements sent from CometChat administration panel.

  • Was this helpful?
  • Yes   No