Skip to main content
The deviceInfo function of the Median JavaScript Bridge returns real-time information about the user’s device and your native app. Use it for analytics, feature compatibility checks, technical support, and advertising attribution.
Developer DemoDisplay our demo page in your app to test during development https://median.dev/device-info

Why use device info?

What data does deviceInfo return?

deviceInfo returns a single object containing the following categories of data: See the field reference for every key returned in the payload.
Important considerations
  • On Android, the carrierNames field requires the READ_PHONE_STATE permission.
  • gaid and idfa are only returned when a supported advertising SDK is configured. See advertising identifiers.
  • median_device_info() is called by the native app as soon as the page loads. The function must be defined at page load time. It can’t be added asynchronously or deferred.

Advertising identifiers (GAID and IDFA)

Median can return two platform-specific advertising identifiers as part of the deviceInfo payload:

Dependency: an advertising SDK is required

gaid and idfa are not returned by default. Median surfaces these values through a supported advertising or attribution SDK, so one of the following plugins must be configured in your app: If none of these plugins is configured, gaid and idfa are omitted from the deviceInfo payload.

IDFA (iOS)

The IDFA is only available after the user grants App Tracking Transparency (ATT) permission. Configure the ATT prompt using Apple App Tracking Transparency. Until ATT permission is granted, idfa returns the zeroed placeholder value:
Check for the placeholder before using IDFAAlways compare idfa against 00000000-0000-0000-0000-000000000000 before using it for attribution. This value means tracking is not yet authorized, not that no identifier exists.

GAID (Android)

The Google Advertising ID is subject to platform limitations that affect its reliability as a tracking identifier:
  • User-resettable: Users can reset their GAID at any time in device settings.
  • Opt-out of personalized ads: Users can disable ad personalization at the OS level.
  • Increasing OS restrictions: Recent Android versions increasingly restrict access to the GAID.
  • Requires Google Play Services: Devices without Google Play Services (for example, Huawei devices) have no GAID, and gaid is omitted regardless of plugin configuration. Treat gaid as a best-effort signal, and handle missing or reset values gracefully in your attribution logic.

Field reference

Integration guide

Website configuration (JavaScript Bridge)

  • Call each page load: If your website defines a function called median_device_info(), it will be called after every page load, as shown below, with an object containing information about your native app and the user’s device.
  • Trigger manually: You may also run median_device_info() manually at any time by calling median.run.deviceInfo().
  • Run via a promise: Call median.deviceInfo().then() or use await median.deviceInfo() to return a promise that resolves with the data.
  • Data processing: You may POST the device data to your server via AJAX, or process it using any other method required in JavaScript.
  • npm package helper method: When using the median-js-bridge npm package, you may call the helper function getPlatform(), which returns web, ios, or android accordingly.

Example deviceInfo payload

Advanced example: enforce a minimum app version

When deploying new features or critical security updates, you may need to ensure all users are running a specific version of your native app. Using deviceInfo, you can retrieve the app version and redirect users to an ā€œUpdate Requiredā€ page if they fall behind your required threshold. Place the following script in your site’s <head>. It uses Semantic Versioning (SemVer) logic to compare the user’s current app version (appVersion) against your required MIN_APP_VERSION.
Version comparison: Version strings aren’t simple numbers (2.10.0 is newer than 2.9.0, but a numerical comparison would suggest otherwise). isVersionLower splits each string into an array of integers so each segment is compared accurately. Using location.replace(): To prevent a redirect loop, use window.location.replace(). This removes the outdated page from browser history so the user can’t navigate back to app content without updating. Handling the deviceInfo promise: Modern implementations return a Promise when calling median.deviceInfo(). Use .then() to handle this asynchronously so the version check runs regardless of when the script loads. User experience (UX): Your update-required.html page should clearly explain why the update is necessary and include direct deep links to the Apple App Store and Google Play Store to minimize friction.

Example app

Last modified on November 7, 2026