# cordova-plugin-mediadrmid

> An Android Cordova plugin that gets a unique, non-resettable id for the device using MediaDrm.

Latest version **0.0.2** (published 2021-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install cordova-plugin-mediadrmid
pnpm add cordova-plugin-mediadrmid
yarn add cordova-plugin-mediadrmid
bun add cordova-plugin-mediadrmid
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-12-16 |
| First published | 2021-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ricardo Sandez |
| Maintainers | ctricardo |
| Keywords | mediadrm, imei, uniqueid, ecosystem:cordova, cordova-android |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-mediadrmid
- Repository: https://github.com/Lietsaki/MediaDrmIdCordovaPlugin
- Issues: https://github.com/Lietsaki/MediaDrmIdCordovaPlugin/issues
- npm.io page: https://npm.io/package/cordova-plugin-mediadrmid

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2021-12-16
- 0.0.1 — 2021-12-16

## README

# MediaDrm Id Cordova Plugin

This plugin allows you to obtain the [PROPERTY_DEVICE_UNIQUE_ID](https://developer.android.com/reference/android/media/MediaDrm#PROPERTY_DEVICE_UNIQUE_ID) of the MediaDrm API in Android devices, which is a signed byte array returned as a string. This can be used to uniquely identify devices in Android +10 (and past versions too), where access to other non-resettable identifiers like the IMEI has been restricted.

The MediaDrm ID persists even after a factory reset. 


# Installation

Install the plugin with npm. If you're using Capacitor, make sure to do it in the directory where capacitor is installed, for example, `src-capacitor` in Quasar Framework.

```
npm i cordova-plugin-mediadrmid
```

Then, if you're using Capacitor, sync the plugin after installing it with the following command:

```
npx cap sync
```

# Usage

The plugin adds a `plugins` property to the `window` object if it didn't exist before, and inside it adds a `MediaDrmId` property with a single method: `get()`.

**Get()**: Returns a promise that resolves with a string containing the device's MediaDrm ID.

Call it using `.then` or `await`, for example:
```
// Using it with .then
document.addEventListener('deviceready', onDeviceReady, false);

function  onDeviceReady() {

	window.plugins.MediaDrmId.get().then(id => {
		console.log('YOUR DEVICE UNIQUE ID:')
		console.log(id)
		// "[-80, 62, 61, 117, -81, 88, 112, -43, 19, 17, 62, 111, 38, 93, -36, 121, -22, 3, 83, -89, -3, 105, -103, -43, -43, -39, -108, 49, 19, 117, -67, -118]"
	}).catch(e => {
		console.log(e)
	})
	
}
```

```
// Using it with await in Vue's onMounted hook
onMounted(async () => {
	const  id  =  await window.plugins.MediaDrmId.get()
	console.log('YOUR DEVICE UNIQUE ID:')
	console.log(id)
	// "[-80, 62, 61, 117, -81, 88, 112, -43, 19, 17, 62, 111, 38, 93, -36, 121, -22, 3, 83, -89, -3, 105, -103, -43, -43, -39, -108, 49, 19, 117, -67, -118]"
})
```

---
_Source: https://npm.io/package/cordova-plugin-mediadrmid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
