|
1 | 1 | # @capacitor/device
|
2 | 2 |
|
3 |
| -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. |
| 3 | +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 | + |
| 5 | +<!--DOCGEN_INDEX_START--> |
| 6 | +* [`getInfo()`](#getinfo) |
| 7 | +* [`getBatteryInfo()`](#getbatteryinfo) |
| 8 | +* [`getLanguageCode()`](#getlanguagecode) |
| 9 | +* [Interfaces](#interfaces) |
| 10 | +<!--DOCGEN_INDEX_END--> |
| 11 | + |
| 12 | +<!--DOCGEN_API_START--> |
| 13 | +<!--Update the source file JSDoc comments and rerun docgen to update the docs below--> |
| 14 | +## API |
| 15 | + |
| 16 | +### getInfo() |
| 17 | + |
| 18 | +```typescript |
| 19 | +getInfo() => Promise<DeviceInfo> |
| 20 | +``` |
| 21 | + |
| 22 | +Return information about the underlying device/os/platform. |
| 23 | + |
| 24 | +**Returns:** <code>Promise<<a href="#deviceinfo">DeviceInfo</a>></code> |
| 25 | + |
| 26 | +**Since:** 1.0.0 |
| 27 | + |
| 28 | +-------------------- |
| 29 | + |
| 30 | + |
| 31 | +### getBatteryInfo() |
| 32 | + |
| 33 | +```typescript |
| 34 | +getBatteryInfo() => Promise<DeviceBatteryInfo> |
| 35 | +``` |
| 36 | + |
| 37 | +Return information about the battery. |
| 38 | + |
| 39 | +**Returns:** <code>Promise<<a href="#devicebatteryinfo">DeviceBatteryInfo</a>></code> |
| 40 | + |
| 41 | +**Since:** 1.0.0 |
| 42 | + |
| 43 | +-------------------- |
| 44 | + |
| 45 | + |
| 46 | +### getLanguageCode() |
| 47 | + |
| 48 | +```typescript |
| 49 | +getLanguageCode() => Promise<DeviceLanguageCodeResult> |
| 50 | +``` |
| 51 | + |
| 52 | +Get the device's current language locale code. |
| 53 | + |
| 54 | +**Returns:** <code>Promise<<a href="#devicelanguagecoderesult">DeviceLanguageCodeResult</a>></code> |
| 55 | + |
| 56 | +**Since:** 1.0.0 |
| 57 | + |
| 58 | +-------------------- |
| 59 | + |
| 60 | + |
| 61 | +### Interfaces |
| 62 | + |
| 63 | + |
| 64 | +#### DeviceInfo |
| 65 | + |
| 66 | +| Prop | Type | Description | Since | |
| 67 | +| --------------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | ----- | |
| 68 | +| **`name`** | <code>string</code> | The name of the device. For example, "John's iPhone". This is only supported on iOS. | 1.0.0 | |
| 69 | +| **`model`** | <code>string</code> | The device model. For example, "iPhone". | 1.0.0 | |
| 70 | +| **`platform`** | <code>"ios" \| "android" \| "web"</code> | The device platform (lowercase). | 1.0.0 | |
| 71 | +| **`uuid`** | <code>string</code> | 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. | 1.0.0 | |
| 72 | +| **`operatingSystem`** | <code>"ios" \| "android" \| "windows" \| "mac" \| "unknown"</code> | The operating system of the device. | 1.0.0 | |
| 73 | +| **`osVersion`** | <code>string</code> | The version of the device OS. | 1.0.0 | |
| 74 | +| **`manufacturer`** | <code>string</code> | The manufacturer of the device. | 1.0.0 | |
| 75 | +| **`isVirtual`** | <code>boolean</code> | Whether the app is running in a simulator/emulator. | 1.0.0 | |
| 76 | +| **`memUsed`** | <code>number</code> | Approximate memory used by the current app, in bytes. Divide by 1048576 to get the number of MBs used. | 1.0.0 | |
| 77 | +| **`diskFree`** | <code>number</code> | How much free disk space is available on the the normal data storage. path for the os, in bytes | 1.0.0 | |
| 78 | +| **`diskTotal`** | <code>number</code> | The total size of the normal data storage path for the OS, in bytes. | 1.0.0 | |
| 79 | + |
| 80 | + |
| 81 | +#### DeviceBatteryInfo |
| 82 | + |
| 83 | +| Prop | Type | Description | Since | |
| 84 | +| ------------------ | -------------------- | ----------------------------------------------------------------- | ----- | |
| 85 | +| **`batteryLevel`** | <code>number</code> | A percentage (0 to 1) indicating how much the battery is charged. | 1.0.0 | |
| 86 | +| **`isCharging`** | <code>boolean</code> | Whether the device is charging. | 1.0.0 | |
| 87 | + |
| 88 | + |
| 89 | +#### DeviceLanguageCodeResult |
| 90 | + |
| 91 | +| Prop | Type | Description | Since | |
| 92 | +| ----------- | ------------------- | ---------------------------- | ----- | |
| 93 | +| **`value`** | <code>string</code> | Two character language code. | 1.0.0 | |
| 94 | + |
| 95 | + |
| 96 | +<!--DOCGEN_API_END--> |
0 commit comments