commit | 05787ac65b71988b360c367521c82897f006fe40 | [log] [tgz] |
---|---|---|
author | Philipp Kursawe <phil.kursawe@gmail.com> | Tue Oct 27 12:34:24 2015 +0100 |
committer | Philipp Kursawe <phil.kursawe@gmail.com> | Tue Oct 27 12:34:24 2015 +0100 |
tree | faacadea3894c8ef2b69667d5e2f4909d861c9a7 | |
parent | 408c3a20be976ca5b814c9f161c31d4edf1c00fc [diff] |
Add `isVirtual` for Windows 8.x (Phone) platforms Sets `isVirtual` to true when: - Running in Simulator on Windows 8.x/10 - Running in Windows Phone 8.x Emulator This also uses the `Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation` to get the manufacturer instead of querying this from the PnP devices. Not tested with Windows 10 Mobile Emulator, but should be the same as Windows 8.1 Phone.
This plugin defines a global device
object, which describes the device's hardware and software. Although the object is in the global scope, it is not available until after the deviceready
event.
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { console.log(device.cordova); }
:warning: Report issues on the Apache Cordova issue tracker
cordova plugin add cordova-plugin-device
Get the version of Cordova running on the device.
The device.model
returns the name of the device's model or product. The value is set by the device manufacturer and may be different across versions of the same product.
// Android: Nexus One returns "Passion" (Nexus One code name) // Motorola Droid returns "voles" // BlackBerry: Torch 9800 returns "9800" // Browser: Google Chrome returns "Chrome" // Safari returns "Safari" // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models // var model = device.model;
Passion
, and Motorola Droid returns voles
.TIZEN
SGH-i917
.Get the device's operating system name.
var string = device.platform;
// Depending on the device, a few examples are: // - "Android" // - "BlackBerry 10" // - Browser: returns "MacIntel" on Mac // returns "Win32" on Windows // - "iOS" // - "WinCE" // - "Tizen" var devicePlatform = device.platform;
Windows Phone 7 devices report the platform as WinCE
.
Windows Phone 8 devices report the platform as Win32NT
.
Get the device's Universally Unique Identifier (UUID).
var string = device.uuid;
The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.
// Android: Returns a random 64-bit integer (as a string, again!) // The integer is generated on the device's first boot // // BlackBerry: Returns the PIN number of the device // This is a nine-digit unique integer (as a string, though!) // // iPhone: (Paraphrased from the UIDevice Class documentation) // Returns the [UIDevice identifierForVendor] UUID which is unique and the same for all apps installed by the same vendor. However the UUID can be different if the user deletes all apps from the vendor and then reinstalls it. Please see https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor // Windows Phone 7 : Returns a hash of device+current user, // if the user is not defined, a guid is generated and will persist until the app is uninstalled // Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number // unique to every GSM and UMTS mobile phone. var deviceID = device.uuid;
The uuid
on iOS uses the identifierForVendor property. It is unique to the device across the same vendor, but will be different for different vendors and will change if all apps from the vendor are deleted and then reinstalled. See https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor The UUID will be the same if app is restored from a backup or iCloud as it is saved in preferences. Users using older versions of this plugin will still receive the same previous UUID generated by another means as it will be retrieved from preferences.
The uuid
for Windows Phone 7 requires the permission ID_CAP_IDENTITY_DEVICE
. Microsoft will likely deprecate this property soon. If the capability is not available, the application generates a persistent guid that is maintained for the duration of the application's installation on the device.
Get the operating system version.
var string = device.version;
// Android: Froyo OS would return "2.2" // Eclair OS would return "2.1", "2.0.1", or "2.0" // Version can also return update level "2.1-update1" // // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" // // Browser: Returns version number for the browser // // iPhone: iOS 3.2 returns "3.2" // // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 // Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384 // Tizen: returns "TIZEN_20120425_2" var deviceVersion = device.version;
whether the device is running on a simulator.
var isSim = device.isVirtual;
Get the device hardware serial number (SERIAL).
var string = device.serial;