Notification Permission & Token
These bridges let your website interact with Firebase push notification settings directly — check or request permission, and retrieve the device's FCM token.
Check Permission Status
Check whether the user has granted push notification permission:
javascript
appilix.postMessage(JSON.stringify({
type: "firebase_notification_permission_status"
}));
appilix.onmessage = function(event) {
const data = JSON.parse(event.data);
if (data.type !== "firebase_notification_permission_status") return;
if (data.status === true) {
// Permission granted
} else {
// Permission not granted
}
appilix.onmessage = null;
};Request Permission
Prompt the user to grant push notification permission. If permission is already granted, nothing is shown. If not, a native dialog appears with your custom text directing the user to app settings:
javascript
appilix.postMessage(JSON.stringify({
type: "firebase_notification_permission",
props: {
description: "Enable notifications to stay updated.",
allow_btn_text: "Allow",
cancel_btn_text: "Not now"
}
}));Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
description | string | No | Message shown in the dialog. Defaults to "Permission Required for Notification" |
allow_btn_text | string | No | Label for the allow button. Defaults to "Allow Permission" |
cancel_btn_text | string | No | Label for the cancel button. Defaults to "Cancel" |
Note: The allow button opens the device's app notification settings — the user must grant permission manually from there. This is required by both Android and iOS.
Get the FCM Token
Retrieve the device's current Firebase Cloud Messaging token:
javascript
appilix.postMessage(JSON.stringify({
type: "firebase_token"
}));
appilix.onmessage = function(event) {
const data = JSON.parse(event.data);
if (data.type !== "firebase_token") return;
console.log("FCM Token:", data.token);
appilix.onmessage = null;
};The data.token will be an empty string if notification permission has not been granted.