Device Info

Call each page load

If your website defines a function called median_device_info(), it will get called after every page load as shown below with an object that contains 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

Return via a promise

Call median.deviceInfo.then() or use await median.deviceInfo() to return a promise that will resolve with the data.


You may POST the device data to your server via AJAX, or anything else that's required using JavaScript.


// You define this function on your page, but do not actually call it
// If present on a page it will be called by the app when the page is loaded
function median_device_info(deviceInfo) {

// You may also call the median_device_info function manually, e.g. on a single page web app;

// Or return the OneSignal Info via a promise (in async function)
var deviceInfo = await median.deviceInfo();

median.deviceInfo().then(function (deviceInfo) {

// deviceInfo will look like
    platform: 'ios',
    appId: 'io.median.example',
    appVersion:  '1.0.0',
    appBuild: '1.0.0', // will be appVersionCode (number) on Android
    carrierNames: ['AT&T'], // array of all connected mobile carriers 
    distribution: 'release',
    hardware: 'armv8',
    installationId: 'xxxx-xxxx-xxxx-xxxx',
    apnsToken: '<xxxxxxxx xxxxxxxx xxxxxxxx ... >', // only on iOS
    language: 'en',
    model: 'iPhone',
    os: 'iOS',
    osVersion: '10.3',
    timeZone: 'America/New_York',
    isFirstLaunch: false // first time the app is launched


The median_device_info() function is called by the native app when the page is loaded within the app. This function must be available at the time of page load and cannot be loaded asynchronously or in a deferred manner.


On Android the parameter carrierNames requires the permission READ_PHONE_STATE