You already used the deviceready
event in Chapter 4, Architecting Your Mobile App, to handle the bootstrap of our app. Use the device API to get information about the type of device you are running once the event is fired.
Open the command-line tool and create a new PhoneGap project using the Cordova-client utility you installed in Chapter 3, Getting Started with Mobile Applications.
$ cordova create ~/the/path/to/your/source DeviceApi
Move to the directory you just created, add the platforms you want to test on the device API and install the device API plugin.
$ cordova platform add android $ cordova platform add ios $ cordova plugin add https: //git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
In the
www
folder inside the project folder you just created, open theindex.html
file and adddiv
withid
to render the device information gathered using the PhoneGap API.<p id='deviceInfo'>Loading device properties...</p>
Define a listener...