openEventsPlatformApp/plugins/cordova-plugin-device/doc/zh/README.md
plugins/cordova-plugin-device/doc/zh/README.mdRaw
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# cordova-plugin-device
21
22[](https://travis-ci.org/apache/cordova-plugin-device)
23
24這個外掛程式定義全球 `device` 物件,描述該設備的硬體和軟體。 雖然物件是在全球範圍內,但不是可用,直到後 `deviceready` 事件。
25
26 document.addEventListener("deviceready", onDeviceReady, false);
27 function onDeviceReady() {
28 console.log(device.cordova);
29 }
30
31
32## 安裝
33
34 cordova plugin add cordova-plugin-device
35
36
37## 屬性
38
39 * device.cordova
40 * device.model
41 * device.platform
42 * device.uuid
43 * device.version
44
45## device.cordova
46
47獲取科爾多瓦在設備上運行的版本。
48
49### 支援的平臺
50
51 * 亞馬遜火 OS
52 * Android 系統
53 * 黑莓 10
54 * 瀏覽器
55 * 火狐瀏覽器作業系統
56 * iOS
57 * Tizen
58 * Windows Phone 7 和 8
59 * Windows 8
60
61## device.model
62
63`device.model`返回設備的模型或產品的名稱。值由設備製造商設置和同一產品的不同版本可能不同。
64
65### 支援的平臺
66
67 * Android 系統
68 * 黑莓 10
69 * 瀏覽器
70 * iOS
71 * Tizen
72 * Windows Phone 7 和 8
73 * Windows 8
74
75### 快速的示例
76
77 // Android: Nexus One returns "Passion" (Nexus One code name)
78 // Motorola Droid returns "voles"
79 // BlackBerry: Torch 9800 returns "9800"
80 // Browser: Google Chrome returns "Chrome"
81 // Safari returns "Safari"
82 // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. 請參閱 HTTP://theiphonewiki.com/wiki/index.php?title=Models / / var 模型 = device.model ;
83
84
85### Android 的怪癖
86
87 * 獲取[產品名稱](http://developer.android.com/reference/android/os/Build.html#PRODUCT)而不是[產品型號名稱](http://developer.android.com/reference/android/os/Build.html#MODEL),這往往是生產代碼名稱。 例如,Nexus One 返回 `Passion` ,和摩托羅拉 Droid 返回`voles`.
88
89### Tizen 怪癖
90
91 * 例如,返回與供應商指派的設備模型`TIZEN`
92
93### Windows Phone 7 和 8 怪癖
94
95 * 返回由製造商指定的設備模型。例如,三星焦點返回`SGH-i917`.
96
97## device.platform
98
99獲取設備的作業系統名稱。
100
101 var string = device.platform;
102
103
104### 支援的平臺
105
106 * Android 系統
107 * 黑莓 10
108 * Browser4
109 * 火狐瀏覽器作業系統
110 * iOS
111 * Tizen
112 * Windows Phone 7 和 8
113 * Windows 8
114
115### 快速的示例
116
117 // Depending on the device, a few examples are:
118 // - "Android"
119 // - "BlackBerry 10"
120 // - Browser: returns "MacIntel" on Mac
121 // returns "Win32" on Windows
122 // - "iOS"
123 // - "WinCE"
124 // - "Tizen"
125 var devicePlatform = device.platform;
126
127
128### Windows Phone 7 的怪癖
129
130Windows Phone 7 設備報告作為平臺`WinCE`.
131
132### Windows Phone 8 怪癖
133
134Windows Phone 8 設備報告作為平臺`Win32NT`.
135
136## device.uuid
137
138獲取設備的通用唯一識別碼 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
139
140 var string = device.uuid;
141
142
143### 說明
144
145如何生成一個 UUID 的細節由設備製造商和特定于設備的平臺或模型。
146
147### 支援的平臺
148
149 * Android 系統
150 * 黑莓 10
151 * iOS
152 * Tizen
153 * Windows Phone 7 和 8
154 * Windows 8
155
156### 快速的示例
157
158 / / Android: 一個隨機的 64 位整數 (作為字串返回,再次!) / / 上設備的第一次啟動生成的整數 / / / / 黑莓手機: 返回設備的 PIN 號碼 / / 這是九個數字的唯一整數 (作為字串,雖然!) / / / / iPhone: (從 UIDevice 類文檔解釋) / / 返回一個字串的雜湊值創建的多個硬體標識。
159 / / 它保證是唯一的每個設備並不能綁 / / 到使用者帳戶。
160 / / Windows Phone 7: 返回的雜湊代碼的設備 + 當前使用者,/ / 如果未定義使用者,則一個 guid 生成的並且將會保留直到卸載該應用程式 / / Tizen: 返回設備 IMEI (國際行動裝置身份或 IMEI 是一個數位 / / 獨有的每一個 UMTS 和 GSM 行動電話。
161 var deviceID = device.uuid;
162
163
164### iOS 怪癖
165
166`uuid`在 iOS 不是唯一的一種裝置,但對於每個應用程式,為每個安裝而異。 如果您刪除並重新安裝該應用程式,它更改和可能還當你升級 iOS,或甚至升級每個版本 (iOS 5.1 中存在明顯的) 的應用程式。 `uuid`不是一個可靠的值。
167
168### Windows Phone 7 和 8 怪癖
169
170`uuid`為 Windows Phone 7 須經許可 `ID_CAP_IDENTITY_DEVICE` 。 Microsoft 可能會很快棄用此屬性。 如果沒有可用的能力,應用程式將生成設備上應用程式的安裝過程中保持持續的 guid。
171
172## device.version
173
174獲取作業系統版本。
175
176 var string = device.version;
177
178
179### 支援的平臺
180
181 * Android 2.1 +
182 * 黑莓 10
183 * 瀏覽器
184 * iOS
185 * Tizen
186 * Windows Phone 7 和 8
187 * Windows 8
188
189### 快速的示例
190
191 // Android: Froyo OS would return "2.2"
192 // Eclair OS would return "2.1", "2.0.1", or "2.0"
193 // Version can also return update level "2.1-update1"
194 //
195 // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
196 //
197 // Browser: Returns version number for the browser
198 //
199 // iPhone: iOS 3.2 returns "3.2"
200 //
201 // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
202 // Tizen: returns "TIZEN_20120425_2"
203 var deviceVersion = device.version;