# Mini-Program Information Management
This module mainly introduces APIs for obtaining Mini-Program information.
# 1. Search Mini-Programs
Supported App Types
Mini-Programā Mini-Gameā H5 Applicationā
To search for Mini-Programs, two steps are required:
- Ensure the server information is configured during SDK initialization;
- Call the search interface to search for Mini-Programs.
# API
/**
* Search Mini-Programs
*
* @param searchAppletRequest Request body
* @param callback Request result callback
*/
fun searchApplet(
searchAppletRequest: SearchAppletRequest,
callback: FinCallback<SearchAppletResponse>
)
SearchAppletRequest Description:
/**
* Search Mini-Program request entity class
*
* @param apiServer Server address
* @param text Search content
*/
data class SearchAppletRequest(var apiServer: String,
var text: String)
SearchAppletResponse Description:
/**
* Search Mini-Program response entity class
*
* @param list Collection of found Mini-Programs
* @param total Number of found Mini-Programs
*/
data class SearchAppletResponse(
val list: List<AppletInfo>?,
val total: Int
)
/**
* Mini-Program information entity class returned from search
*
* @param appId Mini-Program ID
* @param appName Mini-Program name
* @param desc Mini-Program description information
* @param highLights Highlighted text
* @param logo Mini-Program logo
* @param organName Enterprise name
* @param pageUrl Page path found for the Mini-Program
* @param showText Display content
*/
data class AppletInfo(
val appId: String?,
val appName: String?,
val desc: String?,
val highLights: List<HighLight>?,
val logo: String?,
val organName: String?,
val pageUrl: String?,
val showText: String?
)
/**
* Highlighted text
*
* @param key Key of the highlighted text
* @param value Value of the highlighted text
*/
data class HighLight(
val key: String?,
val value: String?
)
# Usage Example
# 2. Get Bound Mini-Program Object Information
Supported App Types
Mini-Programā Mini-Gameā H5 Applicationā
Use this interface to query the list of Mini-Programs bound to the application with different parameters.
fun getBindApplets(
fetchBindAppletRequest: FetchBindAppletRequest,
callback: FinCallback<FetchBindAppletResponse>
)
FetchBindAppletRequest
| Property Name | Type | Description |
|---|---|---|
| apiServer | String | Mini-Program server, required |
| appClass | String | Mini-Program category, default is '' |
| appStatus | AppStatus | Mini-Program status type, enumeration value. 0: All; 1: Published; 2: Unpublished; 3: Taken offline |
| containForbidden | Boolean | Whether the query result includes disabled Mini-Programs, default is false |
| pageNo | Int | Page number for paginated query, default is 1 |
| pageSize | Int | Page size for paginated query, default is 20 |
Return Value
FetchBindAppletResponse
| Property Name | Type | Description |
|---|---|---|
| items | List<FetchBindAppletInfo> | List of Mini-Program objects |
| total | Int | Total number of Mini-Programs matching the criteria |
FetchBindAppletInfo
| Property Name | Type | Description |
|---|---|---|
| apiServer | String | Mini-Program server |
| miniAppId | String | Mini-Program ID |
| name | String | Mini-Program name |
| logo | String | Mini-Program logo |
| appClass | String | Mini-Program category |
| displayStatus | AppStatus | Mini-Program status type, enumeration value. 0: All; 1: Published; 2: Unpublished; 3: Taken offline |
| isForbidden | Boolean | Whether the Mini-Program is disabled |
| desc | String | Mini-Program introduction |
| detailDesc | String | Mini-Program detailed description |
Example Code:
FinAppClient.appletApiManager.getBindApplets(
FetchBindAppletRequest(BuildConfig.API_URL,"Finance"),
object : FinSimpleCallback<FetchBindAppletResponse>() {
override fun onSuccess(result: FetchBindAppletResponse) {
Toast.makeText(application, "getBindApplets onSuccess : $result", Toast.LENGTH_SHORT).show()
}
override fun onError(code: Int, error: String?) {
Toast.makeText(application, "getBindApplets onError : $code, $error", Toast.LENGTH_SHORT).show()
}
})
# 3. Get Mini-Program Object Information
Supported App Types
Mini-Programā Mini-Gameā H5 Applicationā
If obtaining Mini-Program object information in the main process, use the API under appletApiManager in FinAppClient.
# 3.1 Get Mini-Program Information from Running Process Memory in Main Process
/**
* Get Mini-Program information from the memory of the running Mini-Program process
*/
fun getAppletInfoFromRunning(appId: String): FinAppInfo?
# Usage Example
# 3.2 Get Mini-Program Information from Disk in Main Process
/**
* Get Mini-Program information from local disk (only supports official version Mini-Programs)
*/
fun getAppletInfo(appId: String): FinAppInfo?
Example Code:
# 3.3 Get Mini-Program Information in Mini-Program Process
If obtaining Mini-Program information within the Mini-Program process, use the API under appletProcessApiManager in FinAppProcessClient:
/**
* Get the running Mini-Program information
*/
fun getAppletInfo(): FinAppInfo?
Example Code:
# Related Field Descriptions
| Field Name | Description |
|---|---|
| appId | Mini-Program ID |
| codeId | Mini-Program Code Package ID |
| userId | Mini-Program Developer ID |
| appAvatar | Mini-Program Avatar |
| appTitle | Mini-Program Name |
| appDescription | Mini-Program Description |
| appPath | Mini-Program Path |
| appVersion | Mini-Program Version Number |
| appVersionDescription | Mini-Program Version Description |
| sequence | Mini-Program Sequence |
| isGrayVersion | Whether it is a Gray Version |
| appThumbnail | Mini-Program Thumbnail |
| groupId | Organization ID |
| groupName | Organization Name |
| appType | Mini-Program Type |
| createdBy | Mini-Program Developer |
| createdTime | Mini-Program Creation Time |
| startParams | Startup Parameters |
| info | Extended Information |
| fromAppId | Source Mini-Program ID If Mini-Program A opens Mini-Program B by calling navigateToMiniProgram, then for Mini-Program B, fromAppId is Mini-Program A's appId |
| finStoreConfig | Mini-Program App Store Configuration Information |
| frameworkVersion | Base Library Version Number |
| url | Mini-Program Download Address |
| md5 | Mini-Program Full Package MD5 |
# 4. Get Current Mini-Program WebView Information
Supported App Types
Mini-Programā Mini-Gameš« H5 Applicationš«
# 4.1 Get Current webView URL
Only returns the H5 URL if the current page loads H5.
// Main process
FinAppClient.appletApiManager.getCurrentWebViewURL(
object : FinCallback<String> {
override fun onSuccess(result: String?) {
toast("url:$result")
}
override fun onError(code: Int, error: String?) {
}
override fun onProgress(status: Int, info: String?) {
}
})
// Mini-Program process
FinAppProcessClient.appletProcessApiManager.getCurrentWebViewURL(
object : FinCallback<String> {
override fun onSuccess(result: String?) {
toast("url:$result")
}
override fun onError(code: Int, error: String?) {
}
override fun onProgress(status: Int, info: String?) {
}
})
# 4.2 Get Current webView UserAgent
// Main process
FinAppClient.appletApiManager.getCurrentWebViewUserAgent(
object : FinCallback<String> {
override fun onSuccess(result: String?) {
toast("userAgent:$result")
}
override fun onError(code: Int, error: String?) {
}
override fun onProgress(status: Int, info: String?) {
}
})
// Mini-Program process
FinAppProcessClient.appletProcessApiManager.getCurrentWebViewUserAgent(
object : FinCallback<String> {
override fun onSuccess(result: String?) {
toast("userAgent:$result")
}
override fun onError(code: Int, error: String?) {
}
override fun onProgress(status: Int, info: String?) {
}
})
# 4.3 Reload Current webView URL
Only reloads the H5 URL if the current page loads H5.
// Main process
FinAppClient.appletApiManager.reloadCurrentWebView(
object : FinCallback<Any?> {
override fun onSuccess(result: Any?) {
}
override fun onError(code: Int, error: String?) {
}
override fun onProgress(status: Int, info: String?) {
}
})
// Mini-Program process
FinAppProcessClient.appletProcessApiManager.reloadCurrentWebView(
object : FinCallback<Any?> {
override fun onSuccess(result: Any?) {
}
override fun onError(code: Int, error: String?) {
}
override fun onProgress(status: Int, info: String?) {
}
})
# 5. Get Mini-Program Page Screenshot
Supported App Types
Mini-Programā Mini-Gameš« H5 Applicationš«
# API
/**
* Get Mini-Program page screenshot
*
* @param appId Mini-Program ID
* @param snapShotWholePage Whether to capture the entire Mini-Program page (including areas outside the visible range)
* @param callback Mini-Program page screenshot callback
*/
fun captureAppletPicture(
appId: String,
snapShotWholePage: Boolean,
callback: FinCallback<Bitmap?>
)
# Usage Example
# 6. Get Used Mini-Programs
Supported App Types
Mini-Programā Mini-Gameā H5 Applicationā
# 6.1 Get Specific Used Mini-Program
# API
/**
* Get the used Mini-Program for the specified Mini-Program ID
*
* @param appId Mini-Program ID
*/
fun getUsedApplet(appId: String): FinApplet?
# Usage Example
# 6.2 Get List of Used Mini-Programs
# API
/**
* Get all used Mini-Programs
*/
fun getUsedApplets(): List<FinApplet>
# Usage Example
# 6.3 Check if Mini-Program is Used
# API
/**
* Check if the Mini-Program is used
*/
fun isUsedApplet(appId: String): Boolean
# Usage Example
# 7. Get Current Mini-Program ID
Supported App Types
Mini-Programā Mini-Gameā H5 Applicationā
# API
/**
* Get the current Mini-Program ID
*/
fun getCurrentAppletId(): String?
# Usage Example
# 8. Convert WeChat Mini-Program QR Code Information to FinClip Mini-Program
Supported App Types
Mini-Programā Mini-Gameā H5 Applicationš«
The usage scenario for this API is when a Mini-Program is published on both WeChat and FinClip services, it can be associated with the WeChat Mini-Program on the FinClip platform. At this point, the online QR code on the FinClip platform can be scanned and opened using WeChat, or scanned and opened using the FinClip App or other APPs integrated with the FinClip Mini-Program SDK.
The process is to first scan the QR code to obtain the QR code content, then call this interface to get the FinClip Mini-Program ID, and finally call the API to open the Mini-Program.
# API
/**
* Parse Mini-Program information based on WeChat QR Code information
*
* @param qrCode QR Code information
* @param apiServer Server address of the Mini-Program's App Market
* @param callback Result callback
*/
fun parseAppletInfoFromWXQrCode(
qrCode: String,
apiServer: String,
callback: FinSimpleCallback<ParsedAppletInfo?>
)
ParsedAppletInfo structure is as follows:
/**
* Mini-Program information entity class returned from parsing WeChat QR Code information
*
* @param appId Mini-Program ID
*/
data class ParsedAppletInfo(
val appId: String?
)
# Usage Example
# 9. Mini-Program web-view Component Cookie Settings
Supported App Types
Mini-Programā Mini-Gameš« H5 Applicationš«
# 9.1 Set Cookie for Specified URL
# API
/**
* Set Cookie
*
* @param context [Context] instance
* @param appId Mini-Program ID
* @param url URL address for which to set the cookie
* @param cookie Cookie information
*/
fun setCookie(context: Context, appId: String, url: String, cookie: String)
# Usage Example
# 9.2 Delete Cookie for Specified URL
# API
/**
* Remove cookie
*
* @param context [Context] instance
* @param appId Mini-Program ID
* @param url URL address for which to set the cookie
*/
fun removeCookie(context: Context, appId: String, url: String, cookie: String)
# Usage Example
# 9.3 Delete All Cookies
Due to Cookie design, some lower version WebViews synchronize cookies from the main process upon startup. To completely clear cookies, cookies in the main process will also be deleted here.
# API
/**
* Remove all cookies
*
* @param context [Context] instance
* @param appId Mini-Program ID
*/
fun removeAllCookies(context: Context, appId: String)
# Usage Example
# 10. Get Favorite Mini-Programs List
Supported App Types
Mini-Programā Mini-Gameā H5 Applicationā
/**
* Get favorite Mini-Programs list
*
* @param favoriteAppletListRequest Request body
* @param callback Request result callback
*/
fun getFavoriteApplets(
favoriteAppletListRequest: FavoriteAppletListRequest,
callback: FinCallback<FavoriteAppletListResp>
)
Example Code:
val request = FavoriteAppletListRequest("https://api.finclip.com", 1, 5)
FinAppClient.appletApiManager.getFavoriteApplets(request, object: FinSimpleCallback<FavoriteAppletListResp>() {
override fun onSuccess(result: FavoriteAppletListResp) {
Toast.makeText(application, "getFavoriteApplets onSuccess : $result", Toast.LENGTH_SHORT).show()
}
override fun onError(code: Int, error: String?) {
Toast.makeText(application, "getFavoriteApplets onError", Toast.LENGTH_SHORT).show()
}
})