npm.io
1.0.8 • Published 3 years ago

@awesome-cordova-library/device

Licence
SEE LICENSE IN LICENSE
Version
1.0.8
Deps
0
Size
14 kB
Vulns
0
Weekly
0
Stars
7

id: plugin-device title: Device tags:

  • cordova
  • capacitor
  • ionic
  • javascript
  • typescript
  • plugin
  • mobile
  • device

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();
  }, []);
}

Keywords