Permission

Access the information related to permissions granted by cistomer on the app

Description

The permissions variable in the Vajro SDK provides access to the app’s current permission states — primarily used to check whether the device has granted push notification access.

It allows developers to conditionally display prompts, request permissions, or adjust UI behavior depending on whether notifications are enabled or blocked on the user’s device.

Properties

PropertyTypeScopeDescriptionExample
device.permissions.notificationStringGlobalPermission related to Push Notificationsdenied

Example Usage

const permission = VajroSDK.variables.device.permissions.notification;
document.getElementById("test_data_visibility").innerHTML += permission;
if (permission == "denied") {
    VajroSDK.actions.showToast({
        title: "Oops!!",
        message: "Please enable Push."
    });
} else {
    VajroSDK.actions.showToast({
        title: "YAAY!!",
        message: "Push Enabled"
    });
}

Best Practices

  1. Use permission status to adjust your UI — for example, hide “Enable Notifications” buttons if already granted.
  2. Combine this variable with in-app prompts or banners encouraging users to turn on push.
  3. Handle undefined gracefully for optional permissions that may not exist on all devices.
  4. Respect user privacy — never attempt to force or re-request permissions programmatically.

Caveats

  1. The SDK does not automatically request new permissions — it only provides the current state.
  2. If push permission status is unknown, the value may return null until resolved by the system.
  3. Always perform null checks before accessing individual permission keys.