// Find more information here:
// https://github.com/capacitor-community/fcm
import { FCM } from "@capacitor-community/fcm";
import { PushNotifications } from "@capacitor/push-notifications";
// external required step
// register for push
await PushNotifications.requestPermissions();
await PushNotifications.register();
// Subscribe & unsubscribe to the Gleap topics
Gleap.registerListener("registerPushMessageGroup", (topic) => {});
Gleap.setEventCallback((message, err) => {
const { name, data } = message;
if (name === "register-pushmessage-group") {
FCM.subscribeTo({ topic: data })
.then((r) => alert(`subscribed to topic`))
.catch((err) => console.log(err));
}
if (name === "unregister-pushmessage-group") {
FCM.unsubscribeFrom({ topic: data })
.then((r) => alert(`unsubscribed to topic`))
.catch((err) => console.log(err));
}
});