Skip to main content

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.

Online documentation

Cordova documentation

Installation​

Cordova​

cordova plugin add cordova-plugin-device
npm install @awesome-cordova-library/device

Capacitor / Ionic​

npm install cordova-plugin-device
npm install @awesome-cordova-library/device
npx cap sync

Vanilla​

Declaration​

class Device {
static getModel(): string;
static getPlatform(): string;
static getVersion(): string;
static getUuid(): string | null;
static getManufacturer(): string | null;
static getIsVirtual(): boolean;
}

Usages​

import Device from "@awesome-cordova-library/device";

Device.getModel();
Device.getPlatform();
Device.getVersion();
Device.getUuid();
Device.getManufacturer();
Device.getIsVirtual();

React​

Declartion​

const useDevice: () => {
getModel: () => string;
getPlatform: () => string;
getUuid: () => string | null;
getVersion: () => string | null;
getManufacturer: () => string | null;
};

Usages​

import { useEffect } from "react";
import useDevice from "@awesome-cordova-library/device/lib/react";

function App() {
const { getModel, getPlatform, getUuid, getVersion, getManufacturer } =
useDevice();

useEffect(() => {
getModel();
getPlatform();
getUuid();
getVersion();
getManufacturer();
}, []);
}