Device

Access the device / app's information of the customer.

Description

The device variable exposes information about the current device running the app. Use it to tailor layouts or logic based on OS type, screen size, app version and other device characteristics. If a user switches devices or reinstalls the app, they receive a new device identifier.

Properties

PropertyTypeScopeDescriptionExample
device.idStringGlobalUnique Id associated with each deviceD40B48A7-0889-4E76-894
device.localeStringGlobalThe language / region which is set as default in the deviceen_US
device.osEnumGlobalThe operating system of the deviceios
device.osVersionStringGlobalThe version of the Operating system of the device14.2.3
device.windowHeightFloatGlobalThe height of the screen.600
device.windowWidthFloatGlobalThe width of the screen.400
device.vajroVersionStringGlobalThe version of Superfans app installed on the device2.14.6
device.appStoreVersionStringGlobalThe latest version of the app from app store / play store1.0.0
device.pushNotificationStatusEnumGlobalThe permission the end user has granted for push on the device.allowed | not_allowed

Example usage


const device_details = VajroSDK.variables.device;

// Example: adjust layout for larger screens
if (device_details.windowWidth < 600) {
  // Render a screen specific layout
}

// Display the OS and version
console.log(`Running on ${device.os} ${device.osVersion}`);

// Check push notification permission
if (device.pushNotificationStatus === 'not_allowed') {
  // Prompt the user to enable notifications
}

Best Practices

  1. Responsive design: Use windowWidth and windowHeight to adapt layouts to different screen sizes.
  2. Handle enum values: For os and pushNotificationStatus, always handle all supported values (e.g. ios vs. android, allowed vs. not_allowed)
  3. Do not treat device.id as a persistent user ID: It changes if the app is reinstalled or installed on another device.
  4. Read‑only fields: Device properties are read‑only; attempting to modify them has no effect.

Caveats

  1. device.id is specific to the physical device and installation; new installations generate new IDs
  2. On very old OS versions, some fields might not be populated; always check that a field exists before using it.
  3. Push notification status (allowed or not_allowed) reflects the user’s choice and may change if they update permissions in their system settings.