Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor/device

Package Overview
Dependencies
Maintainers
12
Versions
691
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@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.

  • 4.0.2-nightly-20220928T151024.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
127K
decreased by-0.23%
Maintainers
12
Weekly downloads
 
Created
Source

@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()
  • getInfo()
  • getBatteryInfo()
  • getLanguageCode()
  • getLanguageTag()
  • Interfaces
  • Type Aliases

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


getLanguageTag()

getLanguageTag() => Promise<LanguageTag>

Get the device's current language locale tag.

Returns: Promise<LanguageTag>

Since: 4.0.0


Interfaces

DeviceId
PropTypeDescriptionSince
uuidstringThe 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. If localStorage is not available a new random identifier will be generated on every call.1.0.0
DeviceInfo
PropTypeDescriptionSince
namestringThe name of the device. For example, "John's iPhone". This is only supported on iOS and Android 7.1 or above.1.0.0
modelstringThe device model. For example, "iPhone13,4".1.0.0
platform'ios' | 'android' | 'web'The device platform (lowercase).1.0.0
operatingSystemOperatingSystemThe operating system of the device.1.0.0
osVersionstringThe version of the device OS.1.0.0
manufacturerstringThe manufacturer of the device.1.0.0
isVirtualbooleanWhether the app is running in a simulator/emulator.1.0.0
memUsednumberApproximate memory used by the current app, in bytes. Divide by 1048576 to get the number of MBs used.1.0.0
diskFreenumberHow much free disk space is available on the normal data storage path for the os, in bytes. On Android it returns the free disk space on the "system" partition holding the core Android OS. On iOS this value is not accurate.1.0.0
diskTotalnumberThe total size of the normal data storage path for the OS, in bytes. On Android it returns the disk space on the "system" partition holding the core Android OS.1.0.0
realDiskFreenumberHow much free disk space is available on the normal data storage, in bytes.1.1.0
realDiskTotalnumberThe total size of the normal data storage path, in bytes.1.1.0
webViewVersionstringThe web view browser version1.0.0
BatteryInfo
PropTypeDescriptionSince
batteryLevelnumberA percentage (0 to 1) indicating how much the battery is charged.1.0.0
isChargingbooleanWhether the device is charging.1.0.0
GetLanguageCodeResult
PropTypeDescriptionSince
valuestringTwo character language code.1.0.0
LanguageTag
PropTypeDescriptionSince
valuestringReturns a well-formed IETF BCP 47 language tag.4.0.0

Type Aliases

OperatingSystem

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

Keywords

FAQs

Package last updated on 28 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc