cordova-plugin-mz-device

中文文档
2.0.10发布于 2026/11/03MIT零依赖

从cordova-plugin-device派生

中文使用文档
文档目录29 节
  1. 标题:设备 description:获取设备信息。
  2. 安装
  3. 属性
  4. device.cordova
  5. 支持的平台上
  6. device.model
  7. 支持的平台上
  8. 简单的例子
  9. Android怪癖
  10. device.platform
  11. 支持的平台上
  12. 简单的例子
  13. device.uuid
  14. 描述
  15. 支持的平台上
  16. 简单的例子
  17. iOS怪癖
  18. OSX怪癖
  19. device.version
  20. 支持的平台上
  21. 简单的例子
  22. device.manufacturer
  23. 支持的平台上
  24. 简单的例子
  25. device.isVirtual
  26. 支持的平台上
  27. OSX和浏览器怪癖
  28. device.serial
  29. 支持的平台上

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

改动

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

AppVeyor特拉维斯CI
Build statusBuild Status

cordova-plugin-device

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

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

简单的例子

// 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怪癖

  • 得到了 产品名称 而不是 模型名称,这通常是生产代号。例如,Nexus One返回 Passion摩托罗拉Droid回归 voles。

device.platform

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

var string = device.platform;

支持的平台上

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

简单的例子

// 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).

var string = device.uuid;

描述

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

支持的平台上

  • 安卓
  • iOS
  • 窗户
  • OSX

简单的例子

// 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属性。对于同一家供应商的设备来说,它是唯一的,但对于不同的供应商来说,它会有所不同,如果该供应商的所有应用都被删除然后重新安装,它会发生变化。 参考 在这里 获取详细信息。 如果应用从备份或iCloud中恢复,UUID将是相同的,因为它保存在首选项中。使用此插件的旧版本的用户仍然会收到由另一种方式生成的相同的以前的UUID,因为它将从首选项中检索。

OSX怪癖

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

device.version

获取操作系统版本。

var string = device.version;

支持的平台上

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

简单的例子

// 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
  • 窗户

简单的例子

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

device.isVirtual

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

var isSim = device.isVirtual;

支持的平台上

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

OSX和浏览器怪癖

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

device.serial

获取设备硬件序列号(串行).

var string = device.serial;

支持的平台上

  • 安卓
  • OSX

##发布

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

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

版本与发布记录

cordova-plugin-mz-device 共发布 9 个版本,首次发布于 2021/07/09;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.10latest2026/11/03今天
2.0.92024/12/271.9 年前
2.0.82024/11/112 年前
2.0.72024/11/112 年前
2.0.62024/11/112 年前
2.0.52022/01/114 年前

关于 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 和提交记录判断。