@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 Plugin Usage
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