npm package: @itprovn/miniapp-sdk
Description: Miniapp SDK for Laoapp
Latest version: 0.0.5

# @itprovn/miniapp-sdk

Miniapp SDK for Laoapp

## Install

```bash
npm install @itprovn/miniapp-sdk
npx cap sync
```

## 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)
* [`pickImage(...)`](#pickimage)
* [`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)
* [Interfaces](#interfaces)

</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: number; }>
```

Get network information

**Returns:** <code>Promise&lt;{ conneted: boolean; type: number; }&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: ChooseImageOptions) => Promise<ChooseImageResult>
```

Get a photo from the camera or photo library

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

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

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


### pickImage(...)

```typescript
pickImage(options: ChooseImageOptions) => Promise<ChooseImageResult>
```

Pick an image from the camera or photo library

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

**Returns:** <code>Promise&lt;<a href="#chooseimageresult">ChooseImageResult</a>&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> |

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


### Interfaces


#### ChooseImageResult

| Prop        | Type                |
| ----------- | ------------------- |
| **`image`** | <code>string</code> |


#### ChooseImageOptions

| Prop                  | Type                              |
| --------------------- | --------------------------------- |
| **`source`**          | <code>'camera' \| 'photos'</code> |
| **`cameraDirection`** | <code>'front' \| 'rear'</code>    |
| **`resultType`**      | <code>'uri' \| 'base64'</code>    |


#### ConfigAppViewOptions

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

</docgen-api>