đ Push notifications
Stay connected with your customers by utilizing push notifications to alert them of new chat messages, release notes, and news articles. This will deepen engagement and foster stronger relationships.
Gleap supports Firebase Cloud Messaging to send push notifications to users.
Setup Firebase Cloud Messagingâ
To make use of Gleap Push Notifications you must add the Firebase Cloud Messaging service to your app or website. Learn how to get started with FCM here.
Getting your Firebase Cloud Messaging Tokenâ
Open your project in Firebase and open the project settings.
Click on "Cloud Messaging" and locate the Cloud Messaging API (legacy) section.
Copy the "Server key" and open your Gleap project in the Gleap Dashboard.
Now open the project settings and click "Push notifications". Paste in the server key and hit "Save".
Subscribe to the Gleap user topicâ
The last step to complete the push notification setup is to subscribe to the user topic, which Gleap will send the push notifications to. In order to do so, you will need to register the register & unregister push message topic callbacks.
// Find more information here:
// https://firebase.google.com/docs/cloud-messaging/js/topic-messaging
Gleap.on("unregister-pushmessage-group", (topic) => {
getMessaging()
.unsubscribeFromTopic(registrationTokens, topic)
.then((response) => {
console.log("Successfully subscribed to topic:", response);
})
.catch((error) => {
console.log("Error subscribing to topic:", error);
});
});
Gleap.on("register-pushmessage-group", (topic) => {
getMessaging()
.subscribeToTopic(registrationTokens, topic)
.then((response) => {
console.log("Successfully subscribed to topic:", response);
})
.catch((error) => {
console.log("Error subscribing to topic:", error);
});
});
That's it - build and run your app đ