Push Notifications

FCM Migration Guide

Starting June 20, 2024. Firebase will deprecate the FCM legacy API. To maintain uninterrupted push notification functionality, it is advised to migrate to the new API at your earliest convenience. If you have any questions or concerns, please reach out to us.

This migration guide will assist you in smoothly transitioning from the FCM legacy API to HTTP v1

Step 1: Generate a New Private Key on Firebase Console

  1. Access the Firebase console and select your project.
  2. Navigate to Project settings > Service Accounts.
  3. Click on Generate new private key and confirm by selecting Generate key.
  4. Safely store the downloaded JSON file containing the private key.

Step 2: Register the Service Account Key on the Dashboard

  1. Navigate to Settings and select the +Add button
  1. Upload the service account file to the FCM App JSON section
  1. Once the file is successfully uploaded, click Save changes to save the credential.

Step 3: Test the Push Notification

Once setup is complete, you can send push notifications to your mobile app.

If you have any questions or concerns, please reach out to us

Overview

Qiscus Chat SDK receives push notifications through the Qiscus Chat SDK protocol and Firebase Cloud Messaging (FCM). It depends on usage and other conditions. Default notification is sent by Qiscus Chat SDK protocol. To enable your application to receive FCM push notifications, some setups must be performed in both the Firebase Developer Console and the Qiscus Dashboard.

You can do the following steps to setup push notifications:

  1. Setup Firebase to your Android app
  2. Get FCM Secret Key in Firebase Console
  3. Setup FCM Server key in the Qiscus Chat SDK Dashboard
  4. Register your FCM token in the Qiscus Chat SDK
  5. Handle incoming Message from Push Notification

Starting June 20, 2024. Firebase will deprecate the FCM legacy API. To maintain uninterrupted push notification functionality, it is advised to migrate to the new by following FCM migration guide above. If you have any questions or concerns, please reach out to us

Step 1: Setup Firebase to Your Android App

If you already have setup Firebase in your Android app, you can skip this step and go to next step which is Generate FCM Secret key. Otherwise, you can setup Firebase to your Android app by following these steps.

Step 2: Get FCM Secret Key in Firebase Console

You can get FCM Secret Key by following these steps:

  • On the top of left panel, click the gear icon on Project Overview menu. From the drop-down menu, click Project Settings.
  • Click the Cloud Messaging tab under Settings. On the Project Credentials, find and copy your Server Key.

Step 3: Setup FCM Server Key in The Qiscus Dashboard

You can set FCM Secret Key by following these steps:

  • In the FCM Secret Keys section, click +Add to add your FCM Secret Key,
  • Paste FCM Secret Key value and click Save changes

One App Id can only be associated with one FCM Project, make sure the FCM secret keys are from the same FCM Project, If you already put multiple FCM server keys but they are different FCM project, then our system deletes the related device token and the effect you will not receive FCM notification.

Step 4: Register Your FCM Token to Qiscus Chat SDK

  • First, you need to enable FCM for your application, for example:
Java
Copy
  • To enable FCM in ChatConfig, you need to register FCM token to notify Qiscus Chat SDK, for example:
Java
Copy
  • You need to make sure every time open the app, the FCM token always needs to be registered in Qiscus Chat SDK. To retrieve the current FCM token, you can see below code:
Java
Copy
  • Add the service.AppFirebaseMessagingService in Manifest, for example:
Java
Copy

Make sure always to register FCM token when open the app

Step 5: Handle Incoming Message From Push Notification

After registering your FCM token, you will get data from FCM Qiscus Chat SDK, you can handle by using handleMessageReceived() method, for example:

Java
Copy
  • Set the notification listener by calling setNotificationListener(), in order to show the notification, for example:
Java
Copy

Step 6: Stop Receiving Push Notification

You need to stop receiving Push Notification (PN) when you don't need to receive Push Notification, for example when logout from Qiscus system. To stop receiving the PN , you can see below code:

Java
Copy

Notification Payload

Here complete payload of Qiscus Push Notifications. You can define Push Notification from Qiscus Chat SDK which has qiscus_sdk key within Firebase Cloud Messaging response.

JSON
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard