---
name: "getCurrentVolumeByMode"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "3.3.3" }
  - { name: "@ray-js/ray", version: "1.4.57" }
platform:
  - "iOS"
  - "Android"
async: true
---

## getCurrentVolumeByMode

> [VERSION] BaseKit >= 3.3.3 | @ray-js/ray >= 1.4.57

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Get system volume in different modes. Note: On Android, you can get volumes for different system sounds via the volumeMode parameter. On iOS there is only one system volume; volumeMode has no effect.

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `volumeMode` | `number` | No | `2` | `3.3.3` | Volume type (Android only) 0: Voice call volume 1: System sounds 2: Ringer, notifications, system default tones, etc. 3: Media volume 4: Alarm volume 5: Notification volume 6: Bluetooth volume |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `value` | `number` | `3.3.3` | Volume, value range [0–1] |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Examples

#### Demo

```tsx
import { getCurrentVolumeByMode } from '@ray-js/ray'

getCurrentVolumeByMode({
  volumeMode: 2,
  success: data => {
    console.log(data.value);
  },
  fail: error => {
    console.error(error);
  },
});
```
