Skip to content

Commit 15b5b31

Browse files
committed
CB-5658 Add doc.index.md for Device plugin
1 parent fdf4219 commit 15b5b31

File tree

2 files changed

+232
-4
lines changed

2 files changed

+232
-4
lines changed

README.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1-
cordova-plugin-device
2-
-----------------------
3-
To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface).
1+
<!---
2+
license: Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
49
5-
If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html).
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# org.apache.cordova.device
21+
22+
Plugin documentation: [doc/index.md](doc/index.md)

doc/index.md

+211
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
<!---
2+
license: Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# org.apache.cordova.device
21+
22+
This plugin defines a global `device` object, which describes the device's hardware and software.
23+
Although the object is in the global scope, it is not available until after the `deviceready` event.
24+
25+
document.addEventListener("deviceready", onDeviceReady, false);
26+
function onDeviceReady() {
27+
console.log(device.cordova);
28+
}
29+
30+
## Installation
31+
32+
cordova plugin add org.apache.cordova.device
33+
34+
## Properties
35+
36+
- device.cordova
37+
- device.model
38+
- device.name
39+
- device.platform
40+
- device.uuid
41+
- device.version
42+
43+
## device.cordova
44+
45+
Get the version of Cordova running on the device.
46+
47+
### Supported Platforms
48+
49+
- Amazon Fire OS
50+
- Android
51+
- BlackBerry 10
52+
- iOS
53+
- Tizen
54+
- Windows Phone 7 and 8
55+
- Windows 8
56+
57+
## device.model
58+
59+
The `device.model` returns the name of the device's model or
60+
product. The value is set by the device manufacturer and may be
61+
different across versions of the same product.
62+
63+
### Supported Platforms
64+
65+
- Android
66+
- BlackBerry 10
67+
- iOS
68+
- Tizen
69+
- Windows Phone 7 and 8
70+
- Windows 8
71+
72+
### Quick Example
73+
74+
// Android: Nexus One returns "Passion" (Nexus One code name)
75+
// Motorola Droid returns "voles"
76+
// BlackBerry: Torch 9800 returns "9800"
77+
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
78+
//
79+
var model = device.model;
80+
81+
### Android Quirks
82+
83+
- 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`.
84+
85+
### Tizen Quirks
86+
87+
- Returns the device model assigned by the vendor, for example, `TIZEN`
88+
89+
### Windows Phone 7 and 8 Quirks
90+
91+
- Returns the device model specified by the manufacturer. For example, the Samsung Focus returns `SGH-i917`.
92+
93+
## device.name
94+
95+
__WARNING__: `device.name` is deprecated as of version 2.3.0. Use `device.model` instead.
96+
97+
## device.platform
98+
99+
Get the device's operating system name.
100+
101+
var string = device.platform;
102+
103+
### Supported Platforms
104+
105+
- Android
106+
- BlackBerry 10
107+
- iOS
108+
- Tizen
109+
- Windows Phone 7 and 8
110+
- Windows 8
111+
112+
### Quick Example
113+
114+
// Depending on the device, a few examples are:
115+
// - "Android"
116+
// - "BlackBerry 10"
117+
// - "iOS"
118+
// - "WinCE"
119+
// - "Tizen"
120+
var devicePlatform = device.platform;
121+
122+
### Windows Phone 7 Quirks
123+
124+
Windows Phone 7 devices report the platform as `WinCE`.
125+
126+
### Windows Phone 8 Quirks
127+
128+
Windows Phone 8 devices report the platform as `Win32NT`.
129+
130+
## device.uuid
131+
132+
Get the device's Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
133+
134+
var string = device.uuid;
135+
136+
### Description
137+
138+
The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.
139+
140+
### Supported Platforms
141+
142+
- Android
143+
- BlackBerry 10
144+
- iOS
145+
- Tizen
146+
- Windows Phone 7 and 8
147+
- Windows 8
148+
149+
### Quick Example
150+
151+
// Android: Returns a random 64-bit integer (as a string, again!)
152+
// The integer is generated on the device's first boot
153+
//
154+
// BlackBerry: Returns the PIN number of the device
155+
// This is a nine-digit unique integer (as a string, though!)
156+
//
157+
// iPhone: (Paraphrased from the UIDevice Class documentation)
158+
// Returns a string of hash values created from multiple hardware identifies.
159+
// It is guaranteed to be unique for every device and can't be tied
160+
// to the user account.
161+
// Windows Phone 7 : Returns a hash of device+current user,
162+
// if the user is not defined, a guid is generated and will persist until the app is uninstalled
163+
// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
164+
// unique to every GSM and UMTS mobile phone.
165+
var deviceID = device.uuid;
166+
167+
### iOS Quirk
168+
169+
The `uuid` on iOS is not unique to a device, but varies for each
170+
application, for each installation. It changes if you delete and
171+
re-install the app, and possibly also when you upgrade iOS, or even
172+
upgrade the app per version (apparent in iOS 5.1). The `uuid` is not
173+
a reliable value.
174+
175+
### Windows Phone 7 and 8 Quirks
176+
177+
The `uuid` for Windows Phone 7 requires the permission
178+
`ID_CAP_IDENTITY_DEVICE`. Microsoft will likely deprecate this
179+
property soon. If the capability is not available, the application
180+
generates a persistent guid that is maintained for the duration of the
181+
application's installation on the device.
182+
183+
## device.version
184+
185+
Get the operating system version.
186+
187+
var string = device.version;
188+
189+
### Supported Platforms
190+
191+
- Android 2.1+
192+
- BlackBerry 10
193+
- iOS
194+
- Tizen
195+
- Windows Phone 7 and 8
196+
- Windows 8
197+
198+
### Quick Example
199+
200+
// Android: Froyo OS would return "2.2"
201+
// Eclair OS would return "2.1", "2.0.1", or "2.0"
202+
// Version can also return update level "2.1-update1"
203+
//
204+
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
205+
//
206+
// iPhone: iOS 3.2 returns "3.2"
207+
//
208+
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
209+
// Tizen: returns "TIZEN_20120425_2"
210+
var deviceVersion = device.version;
211+

0 commit comments

Comments
 (0)