Push Permission Status Change
Description
The onPermissionStatusChanged listener triggers whenever the device’s permission state changes for supported features — most importantly Push Notification permissions.
This listener is essential for detecting when a user has granted or revoked push permissions, either:
- Immediately after calling
requestPermissions("push"), or - When the user manually enables/disables notifications from device settings.
Use this event to update UI elements, enable push-only features, or prompt users when permissions are denied.
Function Signature
Superfans.listeners.onPermissionStatusChanged(() => {
// Do the necessary logic
});| Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This listener does not require any parameter. |
Example Usage
function checkPushPerm() {
let permission = Superfans.variables.device.permissions.notification;
Superfans.listeners.onPermissionStatusChanged(() => {
document.getElementById("test_data_visibility").innerHTML += permission;
if (permission == "denied") {
Superfans.actions.showToast({
title: "Oops!!",
message: "Please enable Push."
});
Superfans.actions.requestPushPermission();
} else {
Superfans.actions.showToast({
title: "YAAY!!",
message: "Push Enabled"
});
}
});
}
checkPushPerm();Best Practices
- Use this listener after requesting push permissions to determine user action.
- Update UI dynamically — hide "Enable Notifications" button when permission is granted.
- Cache permission status if needed for business logic.
- Show clear, friendly messaging when the user denies permission.
- Consider using this listener during onboarding flows to track permission onboarding success.
Caveats
- Listener fires only after a permission state changes (not on initial load).
- The payload may not include all permissions — only those supported by the device + app version.