# Desktop Integration
This chapter primarily explains how to integrate the SDK into a project and invoke the SDK to launch a Mini-Program. For more detailed usage of the SDK, please refer to the next chapter: SDK Advanced Usage.
Integration Sample Code
Integration sample code can be obtained here: https://github.com/finogeeks/finclip-desktop-demo (opens new window)
If you cannot access GitHub in your environment, you can also click here to access the mirror repository on gitee (opens new window).
# 1. Obtain Credentials
Please Note
Integrating the SDK requires first creating an application and binding a Mini-Program in the FinClip platform. After obtaining the application-specific SDK KEY and SDK SECRET, you can then fill in the corresponding parameters during SDK integration. When opening a Mini-Program, the SDK will automatically initialize and verify whether the SDK KEY, SDK SECRET, and BundleID (Application ID) are correct.
You can 【Click Here】 to see how to obtain the required SDK KEY and SDK SECRET. Please ensure the parameters filled in during SDK integration are correct; otherwise, the Mini-Program will fail to open.
# 2. Obtain and Import the SDK
Download the SDK for the corresponding system from the Official Website's Resource Download Center (opens new window).
The directory structure of the Desktop Edition SDK is as follows:
Finclip.zip
│ FinclipSDKWrapper.(dll | so | dylib) # Dynamic Link Library
│ finclip_api.h # Public Interface Header File
│ finclip_const.h # Constant Definition File
└───FinClip/ # Main Program
# 2.1 Import the SDK
# 2.1.1 Load the Dynamic Link Library
FinClip SDK provides header files and a dynamic link library.
If you are developing with C/C++, please use the provided files directly.
If the language you are using cannot compile directly with header files, please use LoadLibrary / dlopen to load the dynamic link library.
# 2.1.2 Read Functions from the Dynamic Link Library
Using LoadLibrary / dlopen to call functions typically involves the following steps:
- Open the
finclip_api.hfile and find the definition. - Define the function in your target language based on the function declaration.
The following uses finclip_start_applet_params as an example.
- Find its definition as follows:
int finclip_start_applet_params(const char* appstore, const char* appid, void* params);
- Define the function in the language you are using.
# 3. SDK Initialization
After the SDK is successfully loaded, the following introduces the specific API usage methods. All examples use the C language. You can also 【Click Here】 (opens new window) to view the complete demo in the corresponding language.
# 3.1 Configure the SDK
FinclipParams *config = finclip_create_params();
finclip_params_set(config, FINCLIP_CONFIG_APPKEY, appkey);
finclip_params_set(config, FINCLIP_CONFIG_SECRET, secret);
finclip_params_set(config, FINCLIP_CONFIG_DOMAIN, domain);
finclip_params_set(config, FINCLIP_CONFIG_EXE_PATH, exe_path);
finclip_init_with_config(appstore, config);
finclip_destory_params(config);
appstore
The SDK internally maintains a set of server configuration objects, which store various parameters related to starting Mini-Programs. The appstore is the unique identifier for this set of objects. When performing operations like start_applet or init, the current configuration parameters are stored into the server configuration object.
Multiple server configurations can be created and used with different appstore values.
FinClipParams Object
The FinClipParams object is a structure containing several (key, value) pairs, used for data transmission between external code and the SDK to compensate for some limitations of the char* format.
The FinClipParams object is created via methods like finclip_create_params and destroyed with finclip_destory_params.
Note: After each use, it must be manually destroyed using finclip_destory_params.
Only string values are allowed to be set; boolean and numeric values are not permitted.
# 4. Mini-Program Management
# 4.1 Open a Mini-Program
After configuration is complete, you can start a Mini-Program.
// Use the configuration in app_store to open the Mini-Program in the corresponding environment
int finclip_start_applet(const char* appstore, const char* appid);
// Open a Mini-Program with specified parameters
// The set parameters only take effect for the current Mini-Program
// Parameters will override the global parameters set by finclip_init_with_config with higher priority
int finclip_start_applet_params(const char* appstore, const char* appid, FinclipParams* params);
// Open a Mini-Program via QR code
// For trial versions, pass the trial user for qruserid; for temporary and review versions, pass an empty string ("")
int finclip_start_applet_qrcode(const char* appstore, const char* qrcode, const char* qruserid)
# 4.2 Close a Mini-Program
You can close a specified Mini-Program or close all Mini-Programs.
finclip_close_applet(appid); // Close the specified Mini-Program
finclip_close_all_applet(); // Close all Mini-Programs