PhoneGap - Detect device type in phonegap

New in Phonegap, and simplest, is that you can use the device.platform:

// Depending on the device, a few examples are:
//   - "Android"
//   - "BlackBerry"
//   - "iOS"
//   - "webOS"
//   - "WinCE"
//   - "Tizen"
//   - "browser"
var devicePlatform = device.platform;

if you want to get device type before onDeviceReady, you can get like this.

var deviceType = (navigator.userAgent.match(/iPad/i))  == "iPad" ? "iPad" : (navigator.userAgent.match(/iPhone/i))  == "iPhone" ? "iPhone" : (navigator.userAgent.match(/Android/i)) == "Android" ? "Android" : (navigator.userAgent.match(/BlackBerry/i)) == "BlackBerry" ? "BlackBerry" : "null";

alert(deviceType);

cordova.platformId 
// "android"

you can use device.name property to get the detailed info about the device.

    function onDeviceReady() {
    var name=device.name ;
       }

or to get only the platform you can use device.platform property.

    function onDeviceReady() {
    var name=device.name ;
    var plat=device.platform;
       }