Git Product home page Git Product logo

device's Introduction

@capacitor/device

The Device API exposes internal information about the device, such as the model and operating system version, along with user information such as unique ids.

Install

npm install @capacitor/device
npx cap sync

Example

import { Device } from '@capacitor/device';

const logDeviceInfo = async () => {
  const info = await Device.getInfo();

  console.log(info);
};

const logBatteryInfo = async () => {
  const info = await Device.getBatteryInfo();

  console.log(info);
};

API

getId()

getId() => Promise<DeviceId>

Return an unique identifier for the device.

Returns: Promise<DeviceId>

Since: 1.0.0


getInfo()

getInfo() => Promise<DeviceInfo>

Return information about the underlying device/os/platform.

Returns: Promise<DeviceInfo>

Since: 1.0.0


getBatteryInfo()

getBatteryInfo() => Promise<BatteryInfo>

Return information about the battery.

Returns: Promise<BatteryInfo>

Since: 1.0.0


getLanguageCode()

getLanguageCode() => Promise<GetLanguageCodeResult>

Get the device's current language locale code.

Returns: Promise<GetLanguageCodeResult>

Since: 1.0.0


Interfaces

DeviceId

Prop Type Description Since
uuid string The UUID of the device as available to the app. This identifier may change on modern mobile platforms that only allow per-app install UUIDs. On web, a random identifier is generated and stored on localStorage for subsequent calls. 1.0.0

DeviceInfo

Prop Type Description Since
name string The name of the device. For example, "John's iPhone". This is only supported on iOS and Android 7.1 or above. 1.0.0
model string The device model. For example, "iPhone". 1.0.0
platform string The device platform (lowercase). 1.0.0
operatingSystem OperatingSystem The operating system of the device. 1.0.0
osVersion string The version of the device OS. 1.0.0
manufacturer string The manufacturer of the device. 1.0.0
isVirtual boolean Whether the app is running in a simulator/emulator. 1.0.0
memUsed number Approximate memory used by the current app, in bytes. Divide by 1048576 to get the number of MBs used. 1.0.0
diskFree number How much free disk space is available on the the normal data storage. path for the os, in bytes 1.0.0
diskTotal number The total size of the normal data storage path for the OS, in bytes. 1.0.0
webViewVersion string The web view browser version 1.0.0

BatteryInfo

Prop Type Description Since
batteryLevel number A percentage (0 to 1) indicating how much the battery is charged. 1.0.0
isCharging boolean Whether the device is charging. 1.0.0

GetLanguageCodeResult

Prop Type Description Since
value string Two character language code. 1.0.0

Type Aliases

OperatingSystem

'ios' | 'android' | 'windows' | 'mac' | 'unknown'

device's People

Contributors

millerg6711 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.