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
carrierNamesfield requires theREAD_PHONE_STATEpermission. gaidandidfaare 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 thedeviceInfo 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:
- Adjust
- AppsFlyer
- Meta App Events (iOS-only)
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:
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
gaidis omitted regardless of plugin configuration. Treatgaidas 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 callingmedian.run.deviceInfo(). - Run via a promise: Call
median.deviceInfo().then()or useawait median.deviceInfo()to return a promise that resolves with the data. - Data processing: You may
POSTthe 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-bridgenpm package, you may call the helper functiongetPlatform(), which returnsweb,ios, orandroidaccordingly.
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. UsingdeviceInfo, 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.
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.