# cordova-plugin-mz-device 中文文档

规范地址：https://npmcn.com/package/cordova-plugin-mz-device/

版本：2\.0\.10
npm 元数据更新时间：2026-11-03T08:45:08.767Z
中文译文更新时间：2026-11-03T09:27:48.070Z
软件包许可：MIT

本文由上游 README 机器翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/cordova-plugin-mz-device
原文对照：https://npmcn.com/package/cordova-plugin-mz-device/?lang=original
项目主页：https://github.com/happyi/cordova-plugin-mz-devicer#readme
源码仓库：https://github.com/happyi/cordova-plugin-mz-device

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：60.7 kB，15 个文件
- TypeScript 类型：未声明
- 运行依赖：0 个
- 首次发布：2021-07-09T04:26:34.733Z
- 最新版本发布：2026-11-03T08:45:08.414Z
- 已发布版本数：9（近 12 个月 1 个）

## 中文简介

从cordova-plugin-device派生

## 安装

```sh
npm install cordova-plugin-mz-device
```

也可以使用：`pnpm add cordova-plugin-mz-device`、`yarn add cordova-plugin-mz-device`、`bun add cordova-plugin-mz-device`

## README

* * *

## 标题:设备 description：获取设备信息。

# 改动

1、http://www.chinac.chinac.cn/cn/或http://www.chinac.cn/cn/ 2、android . IOS . bundleVersion . bundleAppId 3、android

| AppVeyor | 特拉维斯CI |
| :-: | :-: |
| [![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-device?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-device) | [![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) |

# cordova-plugin-device

这个插件定义了一个全局变量 `device` 对象，该对象描述设备的硬件和软件。 对象虽然在全局作用域中，但直到对象之后才可用 `deviceready` 事件。

```js
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(device.cordova);
}
```

## 安装

```
cordova plugin add cordova-plugin-device
```

## 属性

-   device.cordova
-   device.model
-   device.platform
-   device.uuid
-   device.version
-   device.manufacturer
-   device.isVirtual
-   device.serial

## device.cordova

获取设备上运行的Cordova版本。

### 支持的平台上

-   安卓
-   浏览器
-   iOS
-   窗户
-   OSX

## device.model

这个 `device.model` 返回设备型号或的名称 产品。该值由设备制造商设置，可以是 同一产品的不同版本不同。

### 支持的平台上

-   安卓
-   浏览器
-   iOS
-   窗户
-   OSX

### 简单的例子

```js
// 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
// OSX:                        returns "x86_64"
//
var model = device.model;
```

### Android怪癖

-   得到了 [产品名称](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`。

## device.platform

获取设备的操作系统名称。

```js
var string = device.platform;
```

### 支持的平台上

-   安卓
-   浏览器
-   iOS
-   窗户
-   OSX

### 简单的例子

```js
// Depending on the device, a few examples are:
//   - "Android"
//   - "BlackBerry 10"
//   - "browser"
//   - "iOS"
//   - "WinCE"
//   - "Tizen"
//   - "Mac OS X"
var devicePlatform = device.platform;
```

## device.uuid

获取设备的通用唯一标识符([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)）.

```js
var string = device.uuid;
```

### 描述

UUID如何生成的细节由设备制造商决定，并且特定于设备的平台或型号。

### 支持的平台上

-   安卓
-   iOS
-   窗户
-   OSX

### 简单的例子

```js
// 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.
// 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;
```

### iOS怪癖

这个 `uuid` 在iOS上使用identifierForVendor属性。对于同一家供应商的设备来说，它是唯一的，但对于不同的供应商来说，它会有所不同，如果该供应商的所有应用都被删除然后重新安装，它会发生变化。 参考 [在这里](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor) 获取详细信息。 如果应用从备份或iCloud中恢复，UUID将是相同的，因为它保存在首选项中。使用此插件的旧版本的用户仍然会收到由另一种方式生成的相同的以前的UUID，因为它将从首选项中检索。

### OSX怪癖

这个 `uuid` 如果还不存在，则在OSX上自动生成，并存储在 `standardUserDefaults` 在 `CDVUUID` 财产。

## device.version

获取操作系统版本。

```
var string = device.version;
```

### 支持的平台上

-   Android 2.1 +
-   浏览器
-   iOS
-   窗户
-   OSX

### 简单的例子

```js
// 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"
// OSX:        El Capitan would return "10.11.2"
//
var deviceVersion = device.version;
```

## device.manufacturer

找到设备的制造商。

```
var string = device.manufacturer;
```

### 支持的平台上

-   安卓
-   iOS
-   窗户

### 简单的例子

```js
// Android:    Motorola XT1032 would return "motorola"
// BlackBerry: returns "BlackBerry"
// iPhone:     returns "Apple"
//
var deviceManufacturer = device.manufacturer;
```

## device.isVirtual

设备是否在模拟器上运行。

```js
var isSim = device.isVirtual;
```

### 支持的平台上

-   Android 2.1 +
-   浏览器
-   iOS
-   窗户
-   OSX

### OSX和浏览器怪癖

这个 `isVirtual` 属性在OS X和浏览器上总是返回false。

## device.serial

获取设备硬件序列号([串行](http://developer.android.com/reference/android/os/Build.html#SERIAL)）.

```js
var string = device.serial;
```

### 支持的平台上

-   安卓
-   OSX

##发布

NPM publish——registry=https://registry.npmjs.org/

##安装 添加Cordova -plugin-mz-device

## 常见问题

### cordova-plugin-mz-device 是什么？

从cordova-plugin-device派生

### 如何安装 cordova-plugin-mz-device？

在项目目录运行 npm install cordova-plugin-mz-device，或使用 pnpm add / yarn add / bun add。

### cordova-plugin-mz-device 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/cordova-plugin-mz-device 是否存在。

### cordova-plugin-mz-device 可以商用吗？

cordova-plugin-mz-device 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### cordova-plugin-mz-device 还在维护吗？

最新版本 2\.0\.10 发布于 2026/11/03（今天）；至今共发布 9 个版本，其中过去 12 个月发布了 1 个；首次发布于 2021/07/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

