@sddteam/miniapp-sdk
v0.0.3
Published
Miniapp SDK
Readme
@sddteam/miniapp-sdk
Miniapp SDK
Install
npm install @sddteam/miniapp-sdkAPI
echo(...)getSystemInfo()getUserInfo()getAppInfo()getCurrentLocation()openWebview(...)openMiniapp(...)getNetworkInfo()getAccessToken()scanQr()getPhoto(...)pickImages(...)getBatteryInfo()vibrate(...)setNavigationBarColor(...)setStatusBarColor(...)closeApp()getContacts()saveImageToGallery(...)configAppView(...)requestCameraPermission()isAvailable()verifyIdentity(...)getCredentials(...)setCredentials(...)deleteCredentials(...)getPermissions()requestPermissions(...)getDeviceLanguage()- Interfaces
- Type Aliases
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: string; }>Get network information
Returns: Promise<{ conneted: boolean; type: string; }>
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: CameraOptions) => Promise<Photo>Get a photo from the camera or photo library
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | CameraOptions |
Returns: Promise<Photo>
pickImages(...)
pickImages(options: GalleryPhotosOptions) => Promise<Photo[]>Pick an image from the camera or photo library
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options | GalleryPhotosOptions |
Returns: Promise<Photo[]>
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; } |
getPermissions()
getPermissions() => Promise<{ permissions: Record<string, boolean>; }>Returns: Promise<{ permissions: Record<string, boolean>; }>
requestPermissions(...)
requestPermissions(options: { permissions: string[]; }) => Promise<{ permissions: Record<string, boolean>; }>| Param | Type |
| ------------- | --------------------------------------- |
| options | { permissions: string[]; } |
Returns: Promise<{ permissions: Record<string, boolean>; }>
getDeviceLanguage()
getDeviceLanguage() => Promise<{ language: string; country: string; displayName: string; }>Returns: Promise<{ language: string; country: string; displayName: string; }>
Interfaces
Photo
| Prop | Type |
| ------------------ | ------------------- |
| path | string |
| webPath | string |
| base64String | string |
| dataUrl | string |
CameraOptions
| Prop | Type |
| ------------------------ | --------------------------------------------- |
| resultType | 'uri' | 'base64' | 'dataUrl' |
| saveToGallery | boolean |
| allowEditing | boolean |
| quality | number |
| width | number |
| height | number |
| correctOrientation | boolean |
| cameraDirection | 'front' | 'rear' |
| source | 'CAMERA' | 'PHOTOS' | 'PROMPT' |
GalleryPhotosOptions
| Prop | Type |
| ------------------------ | ------------------------------------------- |
| resultType | 'uri' | 'base64' | 'dataUrl' |
| quality | number |
| limit | number |
| correctOrientation | boolean |
ConfigAppViewOptions
| Prop | Type |
| ------------------------------------ | -------------------------------------------------- |
| hideAndroidBottomNavigationBar | boolean |
| statusBarType | 'normal' | 'hidden' | 'transparent' |
Type Aliases
Record
Construct a type with a set of properties K of type T
{ [P in K]: T; }
