@itprovn/miniapp-sdk
v0.0.5
Published
Miniapp SDK for Laoapp
Readme
@itprovn/miniapp-sdk
Miniapp SDK for Laoapp
Install
npm install @itprovn/miniapp-sdk
npx cap syncAPI
echo(...)getSystemInfo()getUserInfo()getAppInfo()getCurrentLocation()openWebview(...)openMiniapp(...)getNetworkInfo()getAccessToken()scanQr()getPhoto(...)pickImage(...)getBatteryInfo()vibrate(...)setNavigationBarColor(...)setStatusBarColor(...)closeApp()getContacts()saveImageToGallery(...)configAppView(...)requestCameraPermission()isAvailable()verifyIdentity(...)getCredentials(...)setCredentials(...)deleteCredentials(...)- Interfaces
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>Echo a string value
| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
getSystemInfo()
getSystemInfo() => Promise<{ model: string; osName: string; osVersion: string; platform: string; manufacturer?: string; }>Get system information
Returns: Promise<{ model: string; osName: string; osVersion: string; platform: string; manufacturer?: string; }>
getUserInfo()
getUserInfo() => Promise<{ id: string; name: string; phone?: string; email?: string; }>Get user information
Returns: Promise<{ id: string; name: string; phone?: string; email?: string; }>
getAppInfo()
getAppInfo() => Promise<{ id: string; name: string; description?: string; owner?: string; version?: string; }>Get app information
Returns: Promise<{ id: string; name: string; description?: string; owner?: string; version?: string; }>
getCurrentLocation()
getCurrentLocation() => Promise<{ latitude: number; longitude: number; }>Get current location
Returns: Promise<{ latitude: number; longitude: number; }>
openWebview(...)
openWebview(options: { url: string; }) => Promise<void>Open a webview with the given URL
| Param | Type |
| ------------- | ----------------------------- |
| options | { url: string; } |
openMiniapp(...)
openMiniapp(options: { url: string; }) => Promise<void>Open a miniapp with the given URL
| Param | Type |
| ------------- | ----------------------------- |
| options | { url: string; } |
getNetworkInfo()
getNetworkInfo() => Promise<{ conneted: boolean; type: number; }>Get network information
Returns: Promise<{ conneted: boolean; type: number; }>
getAccessToken()
getAccessToken() => Promise<{ clientId: string; accessToken: string; }>Get access token
Returns: Promise<{ clientId: string; accessToken: string; }>
scanQr()
scanQr() => Promise<{ content: string; }>Scan a QR code
Returns: Promise<{ content: string; }>
getPhoto(...)
getPhoto(options: ChooseImageOptions) => Promise<ChooseImageResult>Get a photo from the camera or photo library
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | ChooseImageOptions |
Returns: Promise<ChooseImageResult>
pickImage(...)
pickImage(options: ChooseImageOptions) => Promise<ChooseImageResult>Pick an image from the camera or photo library
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | ChooseImageOptions |
Returns: Promise<ChooseImageResult>
getBatteryInfo()
getBatteryInfo() => Promise<{ level: number; charging: boolean; }>Get battery information
Returns: Promise<{ level: number; charging: boolean; }>
vibrate(...)
vibrate(options: { duration: number; }) => Promise<void>Vibrate the device
| Param | Type |
| ------------- | ---------------------------------- |
| options | { duration: number; } |
setNavigationBarColor(...)
setNavigationBarColor(options: { color: string; }) => Promise<void>Set the navigation bar color
| Param | Type |
| ------------- | ------------------------------- |
| options | { color: string; } |
setStatusBarColor(...)
setStatusBarColor(options: { color: string; }) => Promise<void>Set the status bar color
| Param | Type |
| ------------- | ------------------------------- |
| options | { color: string; } |
closeApp()
closeApp() => Promise<void>Close the app
getContacts()
getContacts() => Promise<{ contacts: { name: string; phone?: string; }[]; }>Get the user's contacts
Returns: Promise<{ contacts: { name: string; phone?: string; }[]; }>
saveImageToGallery(...)
saveImageToGallery(options: { imageBase64Data?: string; imageUrl?: string; }) => Promise<void>Save an image to the gallery
| Param | Type |
| ------------- | ------------------------------------------------------------- |
| options | { imageBase64Data?: string; imageUrl?: string; } |
configAppView(...)
configAppView(options: ConfigAppViewOptions) => Promise<void>Configure the app view
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options | ConfigAppViewOptions |
requestCameraPermission()
requestCameraPermission() => Promise<{ granted: boolean; }>Returns: Promise<{ granted: boolean; }>
isAvailable()
isAvailable() => Promise<{ isAvailable: boolean; biometryType: number; }>Check if biometric auth is available
Returns: Promise<{ isAvailable: boolean; biometryType: number; }>
verifyIdentity(...)
verifyIdentity(options: { useFallback?: boolean; fallbackTitle?: string; }) => Promise<void>| Param | Type |
| ------------- | --------------------------------------------------------------- |
| options | { useFallback?: boolean; fallbackTitle?: string; } |
getCredentials(...)
getCredentials(options: { server: string; }) => Promise<{ username?: string; password?: string; }>| Param | Type |
| ------------- | -------------------------------- |
| options | { server: string; } |
Returns: Promise<{ username?: string; password?: string; }>
setCredentials(...)
setCredentials(options: { server: string; username: string; password: string; }) => Promise<void>| Param | Type |
| ------------- | -------------------------------------------------------------------- |
| options | { server: string; username: string; password: string; } |
deleteCredentials(...)
deleteCredentials(options: { server: string; }) => Promise<void>| Param | Type |
| ------------- | -------------------------------- |
| options | { server: string; } |
Interfaces
ChooseImageResult
| Prop | Type |
| ----------- | ------------------- |
| image | string |
ChooseImageOptions
| Prop | Type |
| --------------------- | --------------------------------- |
| source | 'camera' | 'photos' |
| cameraDirection | 'front' | 'rear' |
| resultType | 'uri' | 'base64' |
ConfigAppViewOptions
| Prop | Type |
| ------------------------------------ | -------------------------------------------------- |
| hideAndroidBottomNavigationBar | boolean |
| hideIOSSafeAreaBottom | boolean |
| statusBarType | 'normal' | 'hidden' | 'transparent' |
