npm package: @startelecom/miniapp-sdk
Description: Miniapp SDK
Latest version: 0.0.5

# @startelecom/miniapp-sdk

Miniapp SDK

## Install

```bash
npm install @startelecom/miniapp-sdk
```

## API

<docgen-index>

* [`echo(...)`](#echo)
* [`getSystemInfo()`](#getsysteminfo)
* [`getUserInfo()`](#getuserinfo)
* [`getAppInfo()`](#getappinfo)
* [`getCurrentLocation()`](#getcurrentlocation)
* [`openWebview(...)`](#openwebview)
* [`openMiniapp(...)`](#openminiapp)
* [`getNetworkInfo()`](#getnetworkinfo)
* [`getAccessToken()`](#getaccesstoken)
* [`scanQr()`](#scanqr)
* [`getPhoto(...)`](#getphoto)
* [`pickImages(...)`](#pickimages)
* [`getBatteryInfo()`](#getbatteryinfo)
* [`vibrate(...)`](#vibrate)
* [`setNavigationBarColor(...)`](#setnavigationbarcolor)
* [`setStatusBarColor(...)`](#setstatusbarcolor)
* [`closeApp()`](#closeapp)
* [`getContacts()`](#getcontacts)
* [`saveImageToGallery(...)`](#saveimagetogallery)
* [`configAppView(...)`](#configappview)
* [`requestCameraPermission()`](#requestcamerapermission)
* [`isAvailable()`](#isavailable)
* [`verifyIdentity(...)`](#verifyidentity)
* [`getCredentials(...)`](#getcredentials)
* [`setCredentials(...)`](#setcredentials)
* [`deleteCredentials(...)`](#deletecredentials)
* [`getPermissions()`](#getpermissions)
* [`requestPermissions(...)`](#requestpermissions)
* [`getDeviceLanguage()`](#getdevicelanguage)
* [`isPedometerAvailable()`](#ispedometeravailable)
* [`getStepsCountTodayOnce()`](#getstepscounttodayonce)
* [`getStepsCountTodayUpdate()`](#getstepscounttodayupdate)
* [`stopStepsCountUpdates()`](#stopstepscountupdates)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### echo(...)

```typescript
echo(options: { value: string; }) => Promise<{ value: string; }>
```

Echo a string value

| Param         | Type                            |
| ------------- | ------------------------------- |
| **`options`** | <code>{ value: string; }</code> |

**Returns:** <code>Promise&lt;{ value: string; }&gt;</code>

--------------------


### getSystemInfo()

```typescript
getSystemInfo() => Promise<{ model: string; osName: string; osVersion: string; platform: string; manufacturer?: string; }>
```

Get system information

**Returns:** <code>Promise&lt;{ model: string; osName: string; osVersion: string; platform: string; manufacturer?: string; }&gt;</code>

--------------------


### getUserInfo()

```typescript
getUserInfo() => Promise<{ id: string; name: string; phone?: string; email?: string; }>
```

Get user information

**Returns:** <code>Promise&lt;{ id: string; name: string; phone?: string; email?: string; }&gt;</code>

--------------------


### getAppInfo()

```typescript
getAppInfo() => Promise<{ id: string; name: string; description?: string; owner?: string; version?: string; }>
```

Get app information

**Returns:** <code>Promise&lt;{ id: string; name: string; description?: string; owner?: string; version?: string; }&gt;</code>

--------------------


### getCurrentLocation()

```typescript
getCurrentLocation() => Promise<{ latitude: number; longitude: number; }>
```

Get current location

**Returns:** <code>Promise&lt;{ latitude: number; longitude: number; }&gt;</code>

--------------------


### openWebview(...)

```typescript
openWebview(options: { url: string; }) => Promise<void>
```

Open a webview with the given URL

| Param         | Type                          |
| ------------- | ----------------------------- |
| **`options`** | <code>{ url: string; }</code> |

--------------------


### openMiniapp(...)

```typescript
openMiniapp(options: { url: string; }) => Promise<void>
```

Open a miniapp with the given URL

| Param         | Type                          |
| ------------- | ----------------------------- |
| **`options`** | <code>{ url: string; }</code> |

--------------------


### getNetworkInfo()

```typescript
getNetworkInfo() => Promise<{ conneted: boolean; type: string; }>
```

Get network information

**Returns:** <code>Promise&lt;{ conneted: boolean; type: string; }&gt;</code>

--------------------


### getAccessToken()

```typescript
getAccessToken() => Promise<{ clientId: string; accessToken: string; }>
```

Get access token

**Returns:** <code>Promise&lt;{ clientId: string; accessToken: string; }&gt;</code>

--------------------


### scanQr()

```typescript
scanQr() => Promise<{ content: string; }>
```

Scan a QR code

**Returns:** <code>Promise&lt;{ content: string; }&gt;</code>

--------------------


### getPhoto(...)

```typescript
getPhoto(options: CameraOptions) => Promise<Photo>
```

Get a photo from the camera or photo library

| Param         | Type                                                    |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#cameraoptions">CameraOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#photo">Photo</a>&gt;</code>

--------------------


### pickImages(...)

```typescript
pickImages(options: GalleryPhotosOptions) => Promise<Photo[]>
```

Pick an image from the camera or photo library

| Param         | Type                                                                  |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | <code><a href="#galleryphotosoptions">GalleryPhotosOptions</a></code> |

**Returns:** <code>Promise&lt;Photo[]&gt;</code>

--------------------


### getBatteryInfo()

```typescript
getBatteryInfo() => Promise<{ level: number; charging: boolean; }>
```

Get battery information

**Returns:** <code>Promise&lt;{ level: number; charging: boolean; }&gt;</code>

--------------------


### vibrate(...)

```typescript
vibrate(options: { duration: number; }) => Promise<void>
```

Vibrate the device

| Param         | Type                               |
| ------------- | ---------------------------------- |
| **`options`** | <code>{ duration: number; }</code> |

--------------------


### setNavigationBarColor(...)

```typescript
setNavigationBarColor(options: { color: string; }) => Promise<void>
```

Set the navigation bar color

| Param         | Type                            |
| ------------- | ------------------------------- |
| **`options`** | <code>{ color: string; }</code> |

--------------------


### setStatusBarColor(...)

```typescript
setStatusBarColor(options: { color: string; }) => Promise<void>
```

Set the status bar color

| Param         | Type                            |
| ------------- | ------------------------------- |
| **`options`** | <code>{ color: string; }</code> |

--------------------


### closeApp()

```typescript
closeApp() => Promise<void>
```

Close the app

--------------------


### getContacts()

```typescript
getContacts() => Promise<{ contacts: { name: string; phone?: string; }[]; }>
```

Get the user's contacts

**Returns:** <code>Promise&lt;{ contacts: { name: string; phone?: string; }[]; }&gt;</code>

--------------------


### saveImageToGallery(...)

```typescript
saveImageToGallery(options: { imageBase64Data?: string; imageUrl?: string; }) => Promise<void>
```

Save an image to the gallery

| Param         | Type                                                          |
| ------------- | ------------------------------------------------------------- |
| **`options`** | <code>{ imageBase64Data?: string; imageUrl?: string; }</code> |

--------------------


### configAppView(...)

```typescript
configAppView(options: ConfigAppViewOptions) => Promise<void>
```

Configure the app view

| Param         | Type                                                                  |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | <code><a href="#configappviewoptions">ConfigAppViewOptions</a></code> |

--------------------


### requestCameraPermission()

```typescript
requestCameraPermission() => Promise<{ granted: boolean; }>
```

**Returns:** <code>Promise&lt;{ granted: boolean; }&gt;</code>

--------------------


### isAvailable()

```typescript
isAvailable() => Promise<{ isAvailable: boolean; biometryType: number; }>
```

Check if biometric auth is available

**Returns:** <code>Promise&lt;{ isAvailable: boolean; biometryType: number; }&gt;</code>

--------------------


### verifyIdentity(...)

```typescript
verifyIdentity(options: { useFallback?: boolean; fallbackTitle?: string; }) => Promise<void>
```

| Param         | Type                                                            |
| ------------- | --------------------------------------------------------------- |
| **`options`** | <code>{ useFallback?: boolean; fallbackTitle?: string; }</code> |

--------------------


### getCredentials(...)

```typescript
getCredentials(options: { server: string; }) => Promise<{ username?: string; password?: string; }>
```

| Param         | Type                             |
| ------------- | -------------------------------- |
| **`options`** | <code>{ server: string; }</code> |

**Returns:** <code>Promise&lt;{ username?: string; password?: string; }&gt;</code>

--------------------


### setCredentials(...)

```typescript
setCredentials(options: { server: string; username: string; password: string; }) => Promise<void>
```

| Param         | Type                                                                 |
| ------------- | -------------------------------------------------------------------- |
| **`options`** | <code>{ server: string; username: string; password: string; }</code> |

--------------------


### deleteCredentials(...)

```typescript
deleteCredentials(options: { server: string; }) => Promise<void>
```

| Param         | Type                             |
| ------------- | -------------------------------- |
| **`options`** | <code>{ server: string; }</code> |

--------------------


### getPermissions()

```typescript
getPermissions() => Promise<{ permissions: Record<string, boolean>; }>
```

**Returns:** <code>Promise&lt;{ permissions: <a href="#record">Record</a>&lt;string, boolean&gt;; }&gt;</code>

--------------------


### requestPermissions(...)

```typescript
requestPermissions(options: { permissions: string[]; }) => Promise<{ permissions: Record<string, boolean>; }>
```

| Param         | Type                                    |
| ------------- | --------------------------------------- |
| **`options`** | <code>{ permissions: string[]; }</code> |

**Returns:** <code>Promise&lt;{ permissions: <a href="#record">Record</a>&lt;string, boolean&gt;; }&gt;</code>

--------------------


### getDeviceLanguage()

```typescript
getDeviceLanguage() => Promise<{ language: string; country: string; displayName: string; }>
```

**Returns:** <code>Promise&lt;{ language: string; country: string; displayName: string; }&gt;</code>

--------------------


### isPedometerAvailable()

```typescript
isPedometerAvailable() => Promise<{ isPedometerAvailable: boolean; }>
```

Checks if the step counting sensor is available on the device.
Returns: { isPedometerAvailable: boolean }

**Returns:** <code>Promise&lt;{ isPedometerAvailable: boolean; }&gt;</code>

--------------------


### getStepsCountTodayOnce()

```typescript
getStepsCountTodayOnce() => Promise<{ steps: number; }>
```

Retrieves the total number of steps taken today (since 00:00:00).
Used for a one-time fetch, it does not start real-time tracking updates.
Returns: { steps: number }

**Returns:** <code>Promise&lt;{ steps: number; }&gt;</code>

--------------------


### getStepsCountTodayUpdate()

```typescript
getStepsCountTodayUpdate() => Promise<{ initialSteps: number; }>
```

Starts tracking steps in real-time.
Returns the initial number of steps taken since the beginning of the day ({ initialSteps: number }).
After calling this method, the SDK will periodically emit the 'measurement' event.
Event Payload: { newSteps: steps taken since the tracking started, totalToday: total steps since the beginning of the day }.
Usage: MiniappSDK.addListener('measurement', (data) =&gt; { ... })

**Returns:** <code>Promise&lt;{ initialSteps: number; }&gt;</code>

--------------------


### stopStepsCountUpdates()

```typescript
stopStepsCountUpdates() => Promise<void>
```

Stops step tracking and halts the 'measurement' events.

--------------------


### Interfaces


#### Photo

| Prop               | Type                |
| ------------------ | ------------------- |
| **`path`**         | <code>string</code> |
| **`webPath`**      | <code>string</code> |
| **`base64String`** | <code>string</code> |
| **`dataUrl`**      | <code>string</code> |


#### CameraOptions

| Prop                     | Type                                          |
| ------------------------ | --------------------------------------------- |
| **`resultType`**         | <code>'uri' \| 'base64' \| 'dataUrl'</code>   |
| **`saveToGallery`**      | <code>boolean</code>                          |
| **`allowEditing`**       | <code>boolean</code>                          |
| **`quality`**            | <code>number</code>                           |
| **`width`**              | <code>number</code>                           |
| **`height`**             | <code>number</code>                           |
| **`correctOrientation`** | <code>boolean</code>                          |
| **`cameraDirection`**    | <code>'front' \| 'rear'</code>                |
| **`source`**             | <code>'CAMERA' \| 'PHOTOS' \| 'PROMPT'</code> |


#### GalleryPhotosOptions

| Prop                     | Type                                        |
| ------------------------ | ------------------------------------------- |
| **`resultType`**         | <code>'uri' \| 'base64' \| 'dataUrl'</code> |
| **`quality`**            | <code>number</code>                         |
| **`limit`**              | <code>number</code>                         |
| **`correctOrientation`** | <code>boolean</code>                        |


#### ConfigAppViewOptions

| Prop                                 | Type                                               |
| ------------------------------------ | -------------------------------------------------- |
| **`hideAndroidBottomNavigationBar`** | <code>boolean</code>                               |
| **`statusBarType`**                  | <code>'normal' \| 'hidden' \| 'transparent'</code> |


### Type Aliases


#### Record

Construct a type with a set of properties K of type T

<code>{ [P in K]: T; }</code>

</docgen-api>