# Mini-Program Management
Mini-Program Management primarily introduces APIs for operating Mini-Programs, including: opening Mini-Programs, closing Mini-Programs, deleting Mini-Programs, Mini-Program Lifecycle, etc.
# 1 Mini-Program Lifecycle
Example
MopSdk.setAppletLifecycleCallback(
(ret) => {
console.log('onInitComplete', ret)
},
(ret) => {
console.log('onOpen', ret)
},
(ret) => {
console.log('onOpenFailure', ret)
},
(ret) => {
console.log('onInActive', ret)
},
(ret) => {
console.log('onActive', ret)
},
(ret) => {
console.log('onClose',ret)
},
(ret) => {
console.log('onDestroy', ret)
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| onInitComplete | Function | Event triggered when Mini-Program initialization is complete and the homepage is loaded |
| onOpen | Function | Event triggered when Mini-Program opening is complete |
| onOpenFailure | Function | Event triggered when Mini-Program encounters an error |
| onInActive | Function | Event triggered when Mini-Program enters an inactive state |
| onActive | Function | Event triggered when Mini-Program enters an active state |
| onClose | Function | Event triggered when Mini-Program closing is complete |
| onDestroy | Function | Event triggered when Mini-Program is destroyed |
# 2 Open Mini-Program Normally
When opening a Mini-Program, it first checks if there is a cached Mini-Program locally. If not, it automatically downloads the Mini-Program from the remote server and then opens it. If there is a cached Mini-Program, it opens the local Mini-Program first, then checks if there is a new version on the server.
If a new version exists, it downloads the new version of the Mini-Program, which will be used the next time it is opened. If there is no new version, no action is taken.
Example
const apiServer = 'https://api.finclip.com'
const appId = '5eec56a41464cc0001852e9a'
MopSdk.openApplet({apiServer,appId},
(ret) => {
console.log('onSuccess',ret)
},
(ret) => {
console.log('onFail',ret)
},
(ret) => {
console.log('onProcess',ret)
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| options | Object | Information for opening the Mini-Program |
| onSuccess | Function | Callback for successful Mini-Program opening |
| onFail | Function | Callback for failed Mini-Program opening |
| onProgress | Function | Callback for Mini-Program opening progress |
options Configuration Items
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program ID, required |
| apiServer | String | Server to which the Mini-Program belongs, required |
| appTitle | String | Mini-Program name, optional |
| appAvatar | String | Network address of the Mini-Program icon, optional |
| startParams | Object | Mini-Program startup parameters, including path and query, optional |
| schemes | Array[String] | Array of custom schemes |
| hideMiniProgramCloseButton | boolean | Whether to hide the close button in the Mini-Program page capsule, default is false |
| hideMiniProgramMoreButton | boolean | Whether to hide the more button in the Mini-Program page capsule, default is false |
| sequence | int | Mini-Program index, optional |
| from | int | Source, recorded in APM events during data reporting |
| anim | String | Animation for opening Mini-Program, Android default is RightToLeft, iOS default is BottomToTop. Options: BottomToTop, LeftToRight, TopToBottom, RightToLeft |
| processMode | String | Process mode. Enum type, default is MULTI (multi-process mode). Options: MULTI, SINGLE (Android only) |
| taskMode | String | Task parameter. Enum type, default is MULTI (multi-task mode). Options: MULTI, SINGLE (Android only) |
| reLaunchMode | String | Mode for executing reLaunch during Mini-Program hot start. Enum type, default is PARAMS_EXIST, meaning reLaunch is executed as long as there are startup parameters (startup parameters are not null or empty string, regardless of whether they are the same as the previous startup parameters) |
startParams Configuration Items
| Configuration Name | Type | Configuration Description |
|---|---|---|
| path | String | Mini-Program page path |
| query | String | Mini-Program parameters, format: key=value&key2=value2 |
# 3 Open Mini-Program via QR Code
This process is generally more complex. It requires scanning a QR code from the FinClip Mini-Program Open Platform to obtain the QR code content, then using that content to call this interface and open the Mini-Program.
Example
const qrCode = '' //QR code
MopSdk.openAppletByQrcode({qrCode},
(ret) => {
console.log('onSuccess',ret)
},
(ret) => {
console.log('onFail',ret)
},
(ret) => {
console.log('onProcess',ret)
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| options | Object | Information for opening the Mini-Program |
| onSuccess | Function | Callback for successful Mini-Program opening |
| onFail | Function | Callback for failed Mini-Program opening |
| onProgress | Function | Callback for Mini-Program opening progress |
options Configuration Items
| Configuration Name | Type | Configuration Description |
|---|---|---|
| qrCode | String | QR code content, required |
| from | int | Source, recorded in APM events during data reporting |
| anim | String | Animation for opening Mini-Program, Android default is RightToLeft, iOS default is BottomToTop. Options: BottomToTop, LeftToRight, TopToBottom, RightToLeft |
| appTitle | String | Mini-Program name, optional (Android only) |
| appAvatar | String | Network address of the Mini-Program icon, optional (Android only) |
| processMode | String | Process mode. Enum type, default is MULTI (multi-process mode). Options: MULTI, SINGLE (Android only) |
| taskMode | String | Task parameter. Enum type, default is MULTI (multi-task mode). Options: MULTI, SINGLE (Android only) |
| schemes | Array[String] | Array of custom schemes (Android only) |
| hideMiniProgramCloseButton | boolean | Whether to hide the close button in the Mini-Program page capsule, default is false (Android only) |
| hideMiniProgramMoreButton | boolean | Whether to hide the more button in the Mini-Program page capsule, default is false (Android only) |
| reLaunchMode | String | Mode for executing reLaunch during Mini-Program hot start. Enum type, default is PARAMS_EXIST, meaning reLaunch is executed as long as there are startup parameters (startup parameters are not null or empty string, regardless of whether they are the same as the previous startup parameters) |
# 4 Search Mini-Programs
Example
const apiServer = ''
const text = ''
MopSdk.searchApplets({apiServer,text},
(ret) => {
console.log('onSuccess',ret)
},
(ret) => {
console.log('onFail',ret)
},
(ret) => {
console.log('onProcess',ret)
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| options | Object | Information for searching Mini-Programs |
| onSuccess | Function | Callback for successful Mini-Program search |
| onFail | Function | Callback for failed Mini-Program search |
| onProgress | Function | Callback for Mini-Program search progress |
options Configuration Items
| Configuration Name | Type | Configuration Description |
|---|---|---|
| apiServer | String | Server address, required |
| text | String | Content to search for Mini-Programs, required |
Success Return Value
| Name | Type | Configuration Description |
|---|---|---|
| list | Array[AppletInfo] | Collection of found Mini-Programs |
| total | int | Number of found Mini-Programs |
AppletInfo Information
| Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program ID |
| appName | String | Mini-Program name |
| desc | String | Mini-Program description information |
| highLights | Array[HighLight] | Highlighted text |
| organName | String | Enterprise name |
| pageUrl | String | Page path found by Mini-Program search |
| showText | String | Display content |
HighLight Information
| Name | Type | Configuration Description |
|---|---|---|
| key | String | Key of the highlighted text |
| value | String | Value of the highlighted text |
# 5 Batch Download Mini-Programs
Example
const apiServer = ''
const appIds = []
MopSdk.downloadApplets({apiServer,appIds},
(ret) => {
console.log('onSuccess',ret)
},
(ret) => {
console.log('onFail',ret)
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| options | Object | Information for batch downloading Mini-Programs |
| onSuccess | Function | Callback for successful batch download of Mini-Programs |
| onFail | Function | Callback for failed batch download of Mini-Programs |
options Configuration Items
| Configuration Name | Type | Configuration Description |
|---|---|---|
| apiServer | String | Server address, required |
| appIds | Array[String] | Array of Mini-Program IDs to download, required |
| isBatchDownloadApplets | boolean | Whether to download these Mini-Programs after obtaining their details, default is false, optional |
Success Return Value
| Name | Type | Configuration Description |
|---|---|---|
| -- | Array[AppletDownLoadInfo] | Collection of downloaded Mini-Programs |
AppletDownLoadInfo Information
| Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program ID |
| success | boolean | Whether the Mini-Program was successfully obtained |
| needUpdate | boolean | Whether the local Mini-Program needs updating. true: Mini-Program source is network; false: Local Mini-Program is already the latest version and does not need downloading (This field is only meaningful when success is true) |
# 6 Get Bound Mini-Program Object Information
Example
const options = {
apiServer: '',
appClass: '',
appStatus: 0,
containForbidden:: false,
pageNo: 1,
pageSize: 20
}
MopSdk.getBindApplets(options,
(ret) => {
console.log('onSuccess',ret)
},
(ret) => {
console.log('onFail',ret)
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| options | Object | Information for batch downloading Mini-Programs |
| onSuccess | Function | Callback for successful batch download of Mini-Programs |
| onFail | Function | Callback for failed batch download of Mini-Programs |
options Configuration Items
| Configuration Name | Type | Configuration Description |
|---|---|---|
| apiServer | String | Server to which the Mini-Program belongs, required |
| appClass | String | Category of the Mini-Program, default is '' |
| appStatus | init | Mini-Program status type, enum value. 0: All; 1: Published; 2: Unpublished; 3: Taken offline |
| containForbiddenApp | boolean | Whether the query result includes forbidden Mini-Programs, default is false |
| pageNo | init | Page number for paginated query, default is 1 |
| pageSize | int | Page size for paginated query, default is 20 |
# 6 Get Mini-Program Page Screenshot
Example
const appId = ''
const snapShotWholePage = false
MopSdk.captureAppletPicture(
appId,
snapShotWholePage
(ret) => {
console.log('onSuccess',ret)
},
(ret) => {
console.log('onFail',ret)
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program ID |
| snapShotWholePage | boolean | Whether to capture the entire Mini-Program page (including areas outside the visible range) |
| onSuccess | Function | Callback for successful Mini-Program screenshot |
| onFail | Function | Callback for failed Mini-Program screenshot |
Success Return Value
| Name | Type | Configuration Description |
|---|---|---|
| bitmap | String | Base64 value of the screenshot |
# 7 Move Mini-Program to Foreground (Android)
Example
const appId = ''
MopSdk.moveMiniProgramToFront(appId)
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program ID |
# 8 Move App to Foreground
Example
MopSdk.moveAppToFront()
Parameters
| Configuration Name | Type | Configuration Description |
|---|
# 9 Get Current Mini-Program APPID Information
Example
MopSdk.currentAppletId((appId) => {
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| onCallback | Function | Callback for successfully obtaining Mini-Program APPID |
# 10 Get Current Mini-Program Information
Example
MopSdk.currentApplet((ret) => {
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| onCallback | Function | Callback for successfully obtaining Mini-Program |
Success Return Value
| Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program ID |
| userId | String | Mini-Program developer ID |
| appAvatar | String | Mini-Program avatar |
| appTitle | String | Mini-Program title |
| appDescription | String | Mini-Program description |
| appVersion | String | Mini-Program version number |
| appVersionDescription | String | Mini-Program version description |
| sequence | int | Mini-Program sequence |
| isGrayVersion | boolean | Whether it is a gray version |
| appThumbnail | String | Mini-Program thumbnail |
| groupId | String | Organization ID to which it belongs |
| groupName | String | Organization name to which it belongs |
| appDescription | String | Mini-Program description |
| startParams | Object | Startup parameters |
# 11 Get Information of a Specific Used Mini-Program
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program APPID |
| onCallback | Function | Callback for successfully obtaining Mini-Program information |
Example
const
MopSdk.getUsedApplet(appId,(FinApplet) => {
})
# 12 Get List of Used Mini-Programs
Example
const
MopSdk.getUsedApplets((Array[FinApplet]) => {
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| onCallback | Function | Callback for successfully obtaining Mini-Program information |
# 13 Check if Mini-Program Has Been Used
Example
const
MopSdk.isUsedApplet(appId,(isUsed) => {
})
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program APPID |
| onCallback | Function | Callback for successfully obtaining Mini-Program information |
# 14 Close Mini-Program (Remains in Memory)
Example
MopSdk.closeApplet(appId);
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program APPID |
# 15 Close All Mini-Programs (Remain in Memory)
Example
MopSdk.closeApplets()
# 16 Finish Mini-Program (Removed from Memory)
Example
MopSdk.finishRunningApplet(appId);
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program APPID |
# 17 Finish All Mini-Programs (Removed from Memory)
Example
MopSdk.finishRunningApplets();
# 18 Clear Mini-Program (Remove from Local Cache)
Example
MopSdk.clearApplet(appId);
Parameters
| Configuration Name | Type | Configuration Description |
|---|---|---|
| appId | String | Mini-Program APPID |
# 19 Clear All Mini-Programs (Remove from Local Cache)
Example
MopSdk.clearApplets()