Chapter 5

Working with the Device, the Network, and Notifications


  • Discovering information about your device
  • Determining the network status
  • Creating custom notifications

In Chapter 4, you learned about PhoneGap life cycle events — how to tell when the device was ready, how to pause and resume your application, and how to tell whether certain buttons were pressed on an Android device.

In this chapter, you take the next logical step and learn more about the device itself, network connectivity, and custom notifications.


PhoneGap has a runtime object called device that holds useful information about the device. Following are the elements of device:

  • — The name of the device (for example, my iPhone)
  • device.phonegap — The version of PhoneGap
  • device.platform — The type of device, (for example, iPhone)
  • device.uuid — The unique number of the device
  • device.Version — The version of the OS that is running

It’s important to note that device is assigned to the window object, so it is implicitly in the global scope. In other words, both of the following variables reference the same device:

//both of these reference the same device
var myPhoneName =;
var myPhoneName =;

In this section, you learn how to get the following:

  • The device’s name
  • The PhoneGap version
  • The device’s platform
  • The device’s Universally Unique Identifier (UUID)
  • The device’s operating system version

Getting ...

Get Beginning PhoneGap now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.