cordova-plugin-mz-device

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

fork from cordova-plugin-device

原始使用文档
文档目录29 节
  1. title: Device description: Get device information.
  2. Installation
  3. Properties
  4. device.cordova
  5. Supported Platforms
  6. device.model
  7. Supported Platforms
  8. Quick Example
  9. Android Quirks
  10. device.platform
  11. Supported Platforms
  12. Quick Example
  13. device.uuid
  14. Description
  15. Supported Platforms
  16. Quick Example
  17. iOS Quirk
  18. OSX Quirk
  19. device.version
  20. Supported Platforms
  21. Quick Example
  22. device.manufacturer
  23. Supported Platforms
  24. Quick Example
  25. device.isVirtual
  26. Supported Platforms
  27. OSX and Browser Quirk
  28. device.serial
  29. Supported Platforms

title: Device description: Get device information.

改动

1、增加异步获取 DeviceInfo 应用市场不允许未接受协议 获取设备信息 2、android 和 IOS 新增 bundleVersion 和 bundleAppId 3、android 新增应用签名信息

AppVeyorTravis CI
Build statusBuild Status

cordova-plugin-device

This plugin defines a global device object, which describes the device's hardware and software. Although the object is in the global scope, it is not available until after the deviceready event.

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

Installation

cordova plugin add cordova-plugin-device

Properties

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

device.cordova

Get the version of Cordova running on the device.

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows
  • OSX

device.model

The device.model returns the name of the device's model or product. The value is set by the device manufacturer and may be different across versions of the same product.

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows
  • OSX

Quick Example

// 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 Quirks

  • Gets the product name instead of the model name, which is often the production code name. For example, the Nexus One returns Passion, and Motorola Droid returns voles.

device.platform

Get the device's operating system name.

var string = device.platform;

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows
  • OSX

Quick Example

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

device.uuid

Get the device's Universally Unique Identifier (UUID).

var string = device.uuid;

Description

The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.

Supported Platforms

  • Android
  • iOS
  • Windows
  • OSX

Quick Example

// 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 Quirk

The 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. Refer here for details. The 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.

OSX Quirk

The uuid on OSX is generated automatically if it does not exist yet and is stored in the standardUserDefaults in the CDVUUID property.

device.version

Get the operating system version.

var string = device.version;

Supported Platforms

  • Android 2.1+
  • Browser
  • iOS
  • Windows
  • OSX

Quick Example

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

Get the device's manufacturer.

var string = device.manufacturer;

Supported Platforms

  • Android
  • iOS
  • Windows

Quick Example

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

device.isVirtual

whether the device is running on a simulator.

var isSim = device.isVirtual;

Supported Platforms

  • Android 2.1+
  • Browser
  • iOS
  • Windows
  • OSX

OSX and Browser Quirk

The isVirtual property on OS X and Browser always returns false.

device.serial

Get the device hardware serial number (SERIAL).

var string = device.serial;

Supported Platforms

  • Android
  • OSX

##发布

npm publish --registry=https://registry.npmjs.org/

##安装 cordova plugin add 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 和提交记录判断。