Skip to main content

Reference

 

Applies only to Mobile Apps
OutSystems

Device

Provides methods to access native capabilities of the device.

Summary

Functions
whenReady Promise that is resolved when the 'deviceready' event is caught.

Functions

whenReady

whenReady(): Promise<void>

Promise that is resolved when the 'deviceready' event is caught.

You should bind your code on this promise (whenReady().then(...)) instead of using the traditional approach of binding the event on document.addEventListener("deviceready", ...). The event fires when Cordova is fully loaded, i.e. it signals that Cordova's device APIs are loaded and are ready for use.

Example:

// get device information
if (cordova) {
  $public.Device.whenReady().then(function() {
    $parameters.DeviceModel = device.model;
    $parameters.CordovaVersion = device.cordova;
    $parameters.Platform = device.platform;
    $parameters.UUID = device.uuid;
    $parameters.Version = device.version;
    $parameters.Manufacturer = device.manufacturer;
    $parameters.IsSimulator = device.isVirtual;
    $parameters.SerialNumber = device.serial;
    $resolve();
  });
} else {
  // fallback when testing on desktop browser
  $resolve();
}

Returns

  • Promise<void>

A Promise object that is fulfilled when the 'deviceready' event is caught.

  • Was this article helpful?