arnaucube
arnaucube/commonroutesServerPublic Self-hosted repository
commonroutesServer/www/plugins/cordova-plugin-device/README.md
www/plugins/cordova-plugin-device/README.mdRaw
  1---
  2title: Device
  3description: Get device information.
  4---
  5<!--
  6# license: Licensed to the Apache Software Foundation (ASF) under one
  7#         or more contributor license agreements.  See the NOTICE file
  8#         distributed with this work for additional information
  9#         regarding copyright ownership.  The ASF licenses this file
 10#         to you under the Apache License, Version 2.0 (the
 11#         "License"); you may not use this file except in compliance
 12#         with the License.  You may obtain a copy of the License at
 13#
 14#           http://www.apache.org/licenses/LICENSE-2.0
 15#
 16#         Unless required by applicable law or agreed to in writing,
 17#         software distributed under the License is distributed on an
 18#         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 19#         KIND, either express or implied.  See the License for the
 20#         specific language governing permissions and limitations
 21#         under the License.
 22-->
 23
 24|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI |
 25|:-:|:-:|:-:|:-:|:-:|:-:|
 26|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device)|
 27
 28# cordova-plugin-device
 29
 30This plugin defines a global `device` object, which describes the device's hardware and software.
 31Although the object is in the global scope, it is not available until after the `deviceready` event.
 32
 33```js
 34document.addEventListener("deviceready", onDeviceReady, false);
 35function onDeviceReady() {
 36    console.log(device.cordova);
 37}
 38```
 39
 40Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
 41
 42
 43## Installation
 44
 45    cordova plugin add cordova-plugin-device
 46
 47## Properties
 48
 49- device.cordova
 50- device.model
 51- device.platform
 52- device.uuid
 53- device.version
 54- device.manufacturer
 55- device.isVirtual
 56- device.serial
 57
 58## device.cordova
 59
 60Get the version of Cordova running on the device.
 61
 62### Supported Platforms
 63
 64- Amazon Fire OS
 65- Android
 66- BlackBerry 10
 67- Browser
 68- Firefox OS
 69- iOS
 70- Tizen
 71- Windows Phone 7 and 8
 72- Windows
 73- OSX
 74
 75## device.model
 76
 77The `device.model` returns the name of the device's model or
 78product. The value is set by the device manufacturer and may be
 79different across versions of the same product.
 80
 81### Supported Platforms
 82
 83- Android
 84- BlackBerry 10
 85- Browser
 86- iOS
 87- Tizen
 88- Windows Phone 7 and 8
 89- Windows
 90- OSX
 91
 92### Quick Example
 93
 94```js
 95// Android:    Nexus One       returns "Passion" (Nexus One code name)
 96//             Motorola Droid  returns "voles"
 97// BlackBerry: Torch 9800      returns "9800"
 98// Browser:    Google Chrome   returns "Chrome"
 99//             Safari          returns "Safari"
100// iOS:     for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
101// OSX:                        returns "x86_64"
102//
103var model = device.model;
104```
105
106### Android Quirks
107
108- Gets the [product name](http://developer.android.com/reference/android/os/Build.html#PRODUCT) instead of the [model name](http://developer.android.com/reference/android/os/Build.html#MODEL), which is often the production code name. For example, the Nexus One returns `Passion`, and Motorola Droid returns `voles`.
109
110### Tizen Quirks
111
112- Returns the device model assigned by the vendor, for example, `TIZEN`
113
114### Windows Phone 7 and 8 Quirks
115
116- Returns the device model specified by the manufacturer. For example, the Samsung Focus returns `SGH-i917`.
117
118## device.platform
119
120Get the device's operating system name.
121
122```js
123var string = device.platform;
124```
125### Supported Platforms
126
127- Android
128- BlackBerry 10
129- Browser
130- Firefox OS
131- iOS
132- Tizen
133- Windows Phone 7 and 8
134- Windows
135- OSX
136
137### Quick Example
138
139```js
140// Depending on the device, a few examples are:
141//   - "Android"
142//   - "BlackBerry 10"
143//   - "browser"
144//   - "iOS"
145//   - "WinCE"
146//   - "Tizen"
147//   - "Mac OS X"
148var devicePlatform = device.platform;
149```
150
151### Windows Phone 7 Quirks
152
153Windows Phone 7 devices report the platform as `WinCE`.
154
155### Windows Phone 8 Quirks
156
157Windows Phone 8 devices report the platform as `Win32NT`.
158
159## device.uuid
160
161Get the device's Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
162
163```js
164var string = device.uuid;
165```
166
167### Description
168
169The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.
170
171### Supported Platforms
172
173- Android
174- BlackBerry 10
175- iOS
176- Tizen
177- Windows Phone 7 and 8
178- Windows
179- OSX
180
181### Quick Example
182
183```js
184// Android: Returns a random 64-bit integer (as a string, again!)
185//          The integer is generated on the device's first boot
186//
187// BlackBerry: Returns the PIN number of the device
188//             This is a nine-digit unique integer (as a string, though!)
189//
190// iPhone: (Paraphrased from the UIDevice Class documentation)
191//         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.
192// Windows Phone 7 : Returns a hash of device+current user,
193// if the user is not defined, a guid is generated and will persist until the app is uninstalled
194// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
195// unique to every GSM and UMTS mobile phone.
196var deviceID = device.uuid;
197```
198
199### iOS Quirk
200
201The `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.
202Refer [here](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor) for details.
203The 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.
204
205### OSX Quirk
206
207The `uuid` on OSX is generated automatically if it does not exist yet and is stored in the `standardUserDefaults` in the `CDVUUID` property.
208
209### Windows Phone 7 and 8 Quirks
210
211The `uuid` for Windows Phone 7 requires the permission
212`ID_CAP_IDENTITY_DEVICE`.  Microsoft will likely deprecate this
213property soon.  If the capability is not available, the application
214generates a persistent guid that is maintained for the duration of the
215application's installation on the device.
216
217## device.version
218
219Get the operating system version.
220
221    var string = device.version;
222
223### Supported Platforms
224
225- Android 2.1+
226- BlackBerry 10
227- Browser
228- iOS
229- Tizen
230- Windows Phone 7 and 8
231- Windows
232- OSX
233
234### Quick Example
235
236```js
237// Android:    Froyo OS would return "2.2"
238//             Eclair OS would return "2.1", "2.0.1", or "2.0"
239//             Version can also return update level "2.1-update1"
240//
241// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
242//
243// Browser:    Returns version number for the browser
244//
245// iPhone:     iOS 3.2 returns "3.2"
246//
247// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
248// Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384
249// Tizen: returns "TIZEN_20120425_2"
250// OSX:        El Capitan would return "10.11.2"
251//
252var deviceVersion = device.version;
253```
254
255## device.manufacturer
256
257Get the device's manufacturer.
258
259    var string = device.manufacturer;
260
261### Supported Platforms
262
263- Android
264- BlackBerry 10
265- iOS
266- Windows Phone 7 and 8
267- Windows
268
269### Quick Example
270
271```js
272// Android:    Motorola XT1032 would return "motorola"
273// BlackBerry: returns "BlackBerry"
274// iPhone:     returns "Apple"
275//
276var deviceManufacturer = device.manufacturer;
277```
278
279## device.isVirtual
280
281whether the device is running on a simulator.
282
283```js
284var isSim = device.isVirtual;
285```
286
287### Supported Platforms
288
289- Android 2.1+
290- iOS
291- Windows Phone 8
292- Windows
293- OSX
294
295### OSX Quirk
296
297The `isVirtual` property on OS X always returns false.
298
299## device.serial
300
301Get the device hardware serial number ([SERIAL](http://developer.android.com/reference/android/os/Build.html#SERIAL)).
302
303```js
304var string = device.serial;
305```
306
307### Supported Platforms
308
309- Android
310- OSX
311