{"id":13428393,"url":"https://github.com/apache/cordova-plugin-device","last_synced_at":"2025-05-14T20:07:53.662Z","repository":{"id":9085298,"uuid":"10860596","full_name":"apache/cordova-plugin-device","owner":"apache","description":"Apache Cordova Device Plugin","archived":false,"fork":false,"pushed_at":"2025-05-06T13:49:14.000Z","size":562,"stargazers_count":389,"open_issues_count":15,"forks_count":426,"subscribers_count":42,"default_branch":"master","last_synced_at":"2025-05-10T17:16:22.417Z","etag":null,"topics":["android","cordova","hacktoberfest","ios","java","javascript","library","mobile","nodejs","objective-c"],"latest_commit_sha":null,"homepage":"https://cordova.apache.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-22T07:00:15.000Z","updated_at":"2025-05-07T07:19:22.000Z","dependencies_parsed_at":"2024-05-31T19:28:36.613Z","dependency_job_id":"4289666d-d712-4d98-8b31-3df82caccb40","html_url":"https://github.com/apache/cordova-plugin-device","commit_stats":{"total_commits":310,"total_committers":81,"mean_commits":"3.8271604938271606","dds":0.8129032258064516,"last_synced_commit":"8685a7ae93be23309fb56bc8d496f4af8d7df9ec"},"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/cordova-plugin-device/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253852570,"owners_count":21973964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cordova","hacktoberfest","ios","java","javascript","library","mobile","nodejs","objective-c"],"created_at":"2024-07-31T01:00:55.664Z","updated_at":"2025-05-14T20:07:53.626Z","avatar_url":"https://github.com/apache.png","language":"JavaScript","readme":"---\ntitle: Device\ndescription: Get device information.\n---\n\u003c!--\n# license: Licensed to the Apache Software Foundation (ASF) under one\n#         or more contributor license agreements.  See the NOTICE file\n#         distributed with this work for additional information\n#         regarding copyright ownership.  The ASF licenses this file\n#         to you under the Apache License, Version 2.0 (the\n#         \"License\"); you may not use this file except in compliance\n#         with the License.  You may obtain a copy of the License at\n#\n#           http://www.apache.org/licenses/LICENSE-2.0\n#\n#         Unless required by applicable law or agreed to in writing,\n#         software distributed under the License is distributed on an\n#         \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n#         KIND, either express or implied.  See the License for the\n#         specific language governing permissions and limitations\n#         under the License.\n--\u003e\n\n# cordova-plugin-device\n\n[![Android Testsuite](https://github.com/apache/cordova-plugin-device/actions/workflows/android.yml/badge.svg)](https://github.com/apache/cordova-plugin-device/actions/workflows/android.yml) [![Chrome Testsuite](https://github.com/apache/cordova-plugin-device/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-device/actions/workflows/chrome.yml) [![iOS Testsuite](https://github.com/apache/cordova-plugin-device/actions/workflows/ios.yml/badge.svg)](https://github.com/apache/cordova-plugin-device/actions/workflows/ios.yml) [![Lint Test](https://github.com/apache/cordova-plugin-device/actions/workflows/lint.yml/badge.svg)](https://github.com/apache/cordova-plugin-device/actions/workflows/lint.yml)\n\nThis plugin defines a global `device` object, which describes the device's hardware and software.\nAlthough the object is in the global scope, it is not available until after the `deviceready` event.\n\n```js\ndocument.addEventListener(\"deviceready\", onDeviceReady, false);\nfunction onDeviceReady() {\n    console.log(device.cordova);\n}\n```\n\n## Installation\n\n    cordova plugin add cordova-plugin-device\n\n## Properties\n\n- device.cordova\n- device.model\n- device.platform\n- device.uuid\n- device.version\n- device.manufacturer\n- device.isVirtual\n- device.serial\n- device.sdkVersion (Android only)\n\n## device.cordova\n\nReturns the Cordova platform's version that is bundled in the application.\n\nThe version information comes from the `cordova.js` file.\n\nThis property does not display other installed platforms' version information. Only the respective running platform's version is displayed.\n\nExample:\n\nIf Cordova Android 10.1.1 is installed on the Cordova project, the `cordova.js` file, in the Android application, will contain `10.1.1`.\n\nThe `device.cordova` property will display `10.1.1`.\n\n### Supported Platforms\n\n- Android\n- Browser\n- iOS\n\n## device.model\n\nThe `device.model` returns the name of the device's model or\nproduct. The value is set by the device manufacturer and may be\ndifferent across versions of the same product.\n\n### Supported Platforms\n\n- Android\n- Browser\n- iOS\n\n### Quick Example\n\n```js\n// Android: Pixel 4             returns \"Pixel 4\"\n//          Motorola Moto G3    returns \"MotoG3\"\n// Browser: Google Chrome       returns \"Chrome\"\n//          Safari              returns \"Safari\"\n// iOS:     iPad Mini           returns \"iPad2,5\"\n//          iPhone 5            returns \"iPhone5,1\"\n// See https://www.theiphonewiki.com/wiki/Models\n// OS X:                        returns \"x86_64\"\n//\nvar model = device.model;\n```\n\n### Android Quirks\n\n- Gets the [model name](https://developer.android.com/reference/android/os/Build.html#MODEL).\n\n### iOS Quirks\n\nThe model value is based on the identifier that Apple supplies.\n\nIf you need the exact device name, e.g. iPhone 13 Pro Max, a mapper needs to be created to convert the known identifiers to the associated device name.\n\nExample: The identifier `iPhone14,3` is associated to the device `iPhone 13 Pro Max`.\n\nFor the full list of all identifiers to device names, see [here](https://www.theiphonewiki.com/wiki/Models)\n\n## device.platform\n\nGet the device's operating system name.\n\n```js\nvar string = device.platform;\n```\n### Supported Platforms\n\n- Android\n- Browser\n- iOS\n\n### Quick Example\n\n```js\n// Depending on the device, a few examples are:\n//   - \"Android\"\n//   - \"browser\"\n//   - \"iOS\"\n//\nvar devicePlatform = device.platform;\n```\n\n## device.uuid\n\nGet the device's Universally Unique Identifier ([UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)).\n\n```js\nvar string = device.uuid;\n```\n\n### Description\n\nThe details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.\n\n### Supported Platforms\n\n- Android\n- iOS\n\n### Quick Example\n\n```js\n// Android: Returns a random 64-bit integer (as a string, again!)\n//\n// iOS: (Paraphrased from the UIDevice Class documentation)\n//         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.\n//\nvar deviceID = device.uuid;\n```\n\n### Android Quirk\n\nThe `uuid` on Android is a 64-bit integer (expressed as a hexadecimal string). The behaviour of this `uuid` is different on two different OS versions-\n\n**For \u003c Android 8.0 (API level 26)**\n\nIn versions of the platform lower than Android 8.0, the `uuid` is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device.\n\n**For Android 8.0 or higher**\n\nThe above behaviour was changed in Android 8.0. Read it in detail [here](https://developer.android.com/about/versions/oreo/android-8.0-changes#privacy-all).\n\nOn Android 8.0 and higher versions, the `uuid` will be unique to each combination of app-signing key, user, and device. The value is scoped by signing key and user. The value may change if a factory reset is performed on the device or if an APK signing key changes.\n\nRead more here https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID.\n\n### iOS Quirk\n\nThe `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.\nRefer [here](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) for details.\nThe 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.\n\n### OS X Quirk\n\nThe `uuid` on OS X is generated automatically if it does not exist yet and is stored in the `standardUserDefaults` in the `CDVUUID` property.\n\n## device.version\n\nGet the operating system version.\n\n    var string = device.version;\n\n### Supported Platforms\n\n- Android\n- Browser\n- iOS\n\n### Quick Example\n\n```js\n// Android:    Froyo OS would return \"2.2\"\n//             Eclair OS would return \"2.1\", \"2.0.1\", or \"2.0\"\n//             Version can also return update level \"2.1-update1\"\n//\n// Browser:    Returns version number for the browser\n//\n// iOS:     iOS 3.2 returns \"3.2\"\n//\nvar deviceVersion = device.version;\n```\n\n## device.manufacturer\n\nGet the device's manufacturer.\n\n    var string = device.manufacturer;\n\n### Supported Platforms\n\n- Android\n- iOS\n\n### Quick Example\n\n```js\n// Android:    Motorola XT1032 would return \"motorola\"\n// iOS:     returns \"Apple\"\n//\nvar deviceManufacturer = device.manufacturer;\n```\n\n## device.isVirtual\n\nwhether the device is running on a simulator.\n\n```js\nvar isSim = device.isVirtual;\n```\n\n## device.sdkVersion (Android only)\n\nGet the Android device's SDK version ([SDK_INT](https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT)).\n\n### Supported Platforms\n\n- Android\n\n### OS X and Browser Quirk\n\nThe `isVirtual` property on OS X and Browser always returns false.\n\n## device.serial\n\nGet the device hardware serial number ([SERIAL](https://developer.android.com/reference/android/os/Build.html#SERIAL)).\n\n```js\nvar string = device.serial;\n```\n\n### Supported Platforms\n\n- Android\n- OS X\n\n### Android Quirk\n\nAs of Android 9, the underlying native API that powered the `uuid` property is deprecated and will always return `UNKNOWN` without proper permissions. Cordova have never implemented handling the required permissions. As of Android 10, **all** non-resettable device identifiers are no longer readable by normal applications and will always return `UNKNOWN`. More information can be [read here](https://developer.android.com/about/versions/10/privacy/changes#non-resettable-device-ids).\n\n## device.isiOSAppOnMac\n\nThe iOS app is running on the Mac desktop (Apple Silicon ARM64 processor, M1 or newer). \nThis parameter is only returned for iOS V14.0 or later, and is not returned for Android devices.\n\n```js\nvar boolean = device.isiOSAppOnMac;\n```\n\n### Supported Platforms\n\n- iOS\n\n---\n\n## iOS Privacy Manifest\n\nAs of May 1, 2024, Apple requires a privacy manifest file to be created for apps and third-party SDKs. The purpose of the privacy manifest file is to explain the data being collected and the reasons for the required APIs it uses. Starting with `cordova-ios@7.1.0`, APIs are available for configuring the privacy manifest file from `config.xml`.\n\nThis plugin comes pre-bundled with a `PrivacyInfo.xcprivacy` file that contains the list of APIs it uses and the reasons for using them.\n\nHowever, as an app developer, it will be your responsibility to identify additional information explaining what your app does with that data.\n\nIn this case, you will need to review the \"[Describing data use in privacy manifests](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_data_use_in_privacy_manifests)\" to understand the list of known `NSPrivacyCollectedDataTypes` and `NSPrivacyCollectedDataTypePurposes`.\n\nFor example, if you collected the device ID for app functionality and analytics, you would write the following in `config.xml`:\n\n```xml\n\u003cplatform name=\"ios\"\u003e\n    \u003cprivacy-manifest\u003e\n        \u003ckey\u003eNSPrivacyTracking\u003c/key\u003e\n        \u003cfalse/\u003e\n        \u003ckey\u003eNSPrivacyTrackingDomains\u003c/key\u003e\n        \u003carray/\u003e\n        \u003ckey\u003eNSPrivacyAccessedAPITypes\u003c/key\u003e\n        \u003carray/\u003e\n        \u003ckey\u003eNSPrivacyCollectedDataTypes\u003c/key\u003e\n        \u003carray\u003e\n            \u003cdict\u003e\n                \u003ckey\u003eNSPrivacyCollectedDataType\u003c/key\u003e\n                \u003cstring\u003eNSPrivacyCollectedDataTypeDeviceID\u003c/string\u003e\n                \u003ckey\u003eNSPrivacyCollectedDataTypeLinked\u003c/key\u003e\n                \u003cfalse/\u003e\n                \u003ckey\u003eNSPrivacyCollectedDataTypeTracking\u003c/key\u003e\n                \u003cfalse/\u003e\n                \u003ckey\u003eNSPrivacyCollectedDataTypePurposes\u003c/key\u003e\n                \u003carray\u003e\n                    \u003cstring\u003eNSPrivacyCollectedDataTypePurposeAnalytics\u003c/string\u003e\n                    \u003cstring\u003eNSPrivacyCollectedDataTypePurposeAppFunctionality\u003c/string\u003e\n                \u003c/array\u003e\n            \u003c/dict\u003e\n        \u003c/array\u003e\n    \u003c/privacy-manifest\u003e\n\u003c/platform\u003e\n```\n\nAlso, ensure all four keys—`NSPrivacyTracking`, `NSPrivacyTrackingDomains`, `NSPrivacyAccessedAPITypes`, and `NSPrivacyCollectedDataTypes`—are defined, even if you are not making an addition to the other items. Apple requires all to be defined.\n","funding_links":[],"categories":["Plugins","JavaScript","Index"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-plugin-device","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fcordova-plugin-device","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-plugin-device/lists"}