Integrate FCM
Integrate FCM (for Web)
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:
-
Integrate the latest version of ZIM SDK. For details, see Getting Started - Integrate the SDK.
-
Integrate the ZPNs SDK. For more, refer to the Implement offline push notification.
-
Complete the Firebase-related steps below:
Go to Firebase, log in with your Google account.
Select Add project, and complete the project information.
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.
After registering, select Service accounts > Generate new private key to generate a JSON config file.
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
Select Cloud Messaging to generate the Web Push certificates.
Copy the firebaseConfig info.
Paste the copied firebaseConfig info to your project, and set up the ZPNs configurations in the project.
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);
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.
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.