LG gathers all the information of the current device before the webView is loaded. You can update the info at anytime to check if anything ha changed (such as the width and height).

Attributes:

  • appVersion: The app version of your application, set in the Settings.plist file.
  • batteryLevel: The battery charge level for the device.
  • batteryState: The battery state for the device. States include: unknown, unplugged, charging, and full.
  • height: The height of the current webView. If a TabBar or NavBar is added, the height attribute will reflect the new webview height.
  • id: A string unique to each device based on various hardware details.
  • lgVersion: LiquidGear version.
  • model: Either iPhone or iPod Touch
  • name: Name identifying the device. This would be the name you gave the device and what is displayed in iTunes.
  • os: Name of the operating system running on the device represented by the receiver.
  • proximity: A Boolean value indicating whether the proximity sensor is close to the user (true) or not (false).
  • version: OS version
  • width: The width of the current webView. If the device view is rotated or changed, it will reflect in the width attribute once the info has been updated.
  • wifi: If the device is using a WiFi connection, the wifi attribute will be set as true.

 

Script

//Add ready listener
lg.bind('lg_init', init);

function init() {
   //Get the version of the OS. Since we have the initial information at launch, we do not need
   //to update for this attribute.
   console.log(lg.info.version);
}

function updateInfo() {
   //Add listener
   lg.bind('lg_info', gotResults);

   //Update with the latest information
   lg.info.update();
}

function gotResults() {
   //Get an updated height
   console.log(lg.info.height);
}