logo
On this page

Integrate FCM

Integrate FCM (for Web)

Note

This article is applicable for integrating Google FCM on Web.

Google FCM (Firebase Cloud Messaging) is a cross-platform messaging solution that lets you reliably deliver messages.

Before using ZIM SDK's offline push notification feature, please implement the Google FCM push notification first by referring to this document.

Prerequisites

  • Platform-specific requirements:
  • The Chrome browser is connected to the Web.
  • Accessible HTTPS domain name or IP address.

Before the push notification implementation using FCM, make sure you complete the following:

1
Log in to Firebase

Go to Firebase, log in with your Google account.

2
Add project

Select Add project, and complete the project information.

3
Create a web application

After a project is added, go to the project detail page.

Then, click the button shown below to create a Web application.

Enter your Application's info, and click Register App.

4
Get a Firebase service account credential

After registering, select Service accounts > Generate new private key to generate a JSON config file.

5
Upload FCM credentials

Log in to the ZEGOCLOUD Admin Console, select Service Management > In-app Chat tab, and add FCM credentials in the Notification configuration session.

Get Web Push certificates

1
Generate the Web Push certificates

Select Cloud Messaging to generate the Web Push certificates.

2
Copy the firebaseConfig info

Copy the firebaseConfig info.

3
Paste the firebaseConfig info

Paste the copied firebaseConfig info to your project, and set up the ZPNs configurations in the project.

Untitled
var appID = 0; // Your Application ID of ZEGO ZIM
var zim = ZIM.create({ appID: appID });

var config = {
    // From firebaseConfig
    apiKey: '',
    authDomain: '',
    projectId: '',
    storageBucket: '',
    messagingSenderId: '',
    appId: '',
    measurementId: '',

    // From Web Push certificates
    vapidKey: '',
}
ZPNs.getInstance().register(config, zim);
1
Copied!
4
Get the firebase-messaging-sw.js file

Navigate to SDK downloads to get the latest version of the ZPNs SDK.

Copy the firebase-messaging-sw.js file from the SDK to the root directory of your project.

5
Contact ZEGOCLOUD Technical Support

Contact ZEGOCLOUD technical support for further configuration after you have completed the steps mentioned above.

After completing the above steps, you can proceed to complete Implement offline push notification.

Previous

Set custom push rules

Next

ResourcesID introduction