# SDK Initialization

Before using the APIs of the Mini-Program, the Mini-Program SDK needs to be initialized. Only after the SDK is successfully initialized can the APIs provided by the SDK be used; otherwise, all API calls will fail.

# 1. Initialization


 ///
/// initialize FinClip SDK.
/// Initialize the SDK (Recommended)
/// [config] is required. SDK configuration
/// [uiConfig] is optional. UI configuration
Future<Map> initSDK(Config config, {UIConfig? uiConfig})

Initialization example:

// 1. Create Config
FinStoreConfig storeConfig = new FinStoreConfig('22LyZEib0gLTQdU3MUauATBwgfnTCJjdr7FCnywmAEM=', 'bdfd76cae24d4313', 'https://api.finclip.com');
Config config = new Config([storeConfig]);
config.userId = 'The unique identifier of your app user';

// 2. Create UIConfig
UIConfig uiConfig = new UIConfig();
uiConfig.isHideAddToDesktopMenu = true;
uiConfig.isHideFeedbackAndComplaints = true;
final res = await Mop.instance.initSDK(config, uiConfig: uiConfig);

The following is an example of initializing the SDK with multiple servers configured:

// 1. Create Config
// 1.1 Configure parameters for Server 1
FinStoreConfig finclip_store = FinStoreConfig('22LyZEib0gLTQdU3MUauATBwgfnTCJjdr7FCnywmAEM=', 'bdfd76cae24d4313', 'https://api.finclip.com');
// 1.2 Configure parameters for Server 2
FinStoreConfig test_store = FinStoreConfig('sdkKey2', 'sdkSecret2', 'Test Server');
Config config = Config([finclip_store, test_store]);
config.userId = 'The unique identifier of your app user';

// Configure corresponding grayscale extension parameters based on AppId // Supported in version 2.49.12 and above
// Prioritizes exact matching by AppId. If it is null or not configured, 'Other' will be used
// A special empty object {} indicates no extension parameters are desired
config.grayAppletVersionConfigs = {
"appId01": {"xxx": "qwer", "aaa": "qaz"}, // For Mini-Program appId01
"appId02": {"yyy": "qwer", "bbb": "wsx"}, // For Mini-Program appId02
"Other": {"zzz": "wee", "ccc": "dad"}, // For other Mini-Programs
};


// 2. Create UIConfig
UIConfig uiConfig = UIConfig();
uiConfig.isHideAddToDesktopMenu = true;
uiConfig.isHideFeedbackAndComplaints = true;

final res = await Mop.instance.initSDK(config, uiConfig: uiConfig);

# FinStoreConfig Configuration Items

Configuration Name Type Required Description
sdkKey String Yes The sdkKey generated when creating the application
sdkSecret String Yes The sdkSecret generated when creating the application
apiServer String Yes Server address, the backend address deployed by the customer
apmServer String No The server address for APM event reporting. Uses apiServer if not set
cryptType String No Network interface encryption type. Default is "MD5", can also be set to "SM" (National Encryption Standard)
fingerprint String No SDK fingerprint. Must be provided in the certificate-linked environment, otherwise interface access will fail
encryptServerData Boolean No Default is false. Currently can only be set to false, setting to true will cause interface access failure
enablePreloadFramework Boolean No Default is true. Whether to pre-download the Base Library. If set to false, the Base Library will not be pre-downloaded during SDK initialization

# 2. Configuration Items

The configuration items during SDK initialization are Config and UIConfig.

  • Config mainly contains configuration items unrelated to the UI;
  • UIConfig mainly contains configuration items related to the UI.

# 2.1 Configuration Items in Config

Configuration Name Type Description
finStoreConfigs List<FinStoreConfig> List of server configuration objects to initialize. For specific parameters, see the FinStoreConfig table
userId String Unique identifier for the current user. Mini-Program cache information will be isolated by userId
channel String Channel identifier. If not set, the application's bundleId is used
phone String Phone number, or a token that corresponds one-to-one with a phone number
productIdentification String Product identifier, affects the cache root directory and the identifier in the userAgent
disableRequestPermissions Boolean Whether to prevent the SDK from triggering permission requests. Default is false. If set to true, APIs within the SDK that use permissions will not actively request permissions.
appletAutoAuthorize Boolean Whether a dialog box is displayed for user confirmation when requesting permissions. Default is false. If set to true, permissions are automatically requested from the SDK without showing a dialog box
disableGetSuperviseInfo Boolean Whether to disable the SDK's regulatory interface API. Default is false. If set to true, the SDK disables the regulatory interface API (getSuperviseInfo)
appletIntervalUpdateLimit int Number of Mini-Programs automatically checked for updates in the background. Valid range: 0~50. 0 means no update check; if not set, default is 3.
apmExtendInfo Map<String, String> Extended information for APM statistics. Map type
startCrashProtection Boolean Whether to enable Crash protection. Default is false (Only supported on iOS). Includes UnrecognizedSelector, KVO, Notification, Timer, Container (array out of bounds, dictionary insertion of nil, etc.), String (out of bounds, nil, etc.)
enableApmDataCompression Boolean Whether to compress data when reporting APM data. Default is false
encryptServerData Boolean Whether the data returned by the platform interface should be encrypted. Default is false.
appletDebugMode BOOLState Whether to enable the Mini-Program's debug mode, i.e., display vConsole.
enableWatermark Boolean Whether to display the watermark. Default is false.
watermarkPriority ConfigPriority Watermark display priority setting. Default is global configuration priority
baseLoadingViewClass String Class name of the custom loading view for the Mini-Program. Only supported on iOS
baseLoadFailedViewClass String Class name of the load failure view for the Mini-Program. Only supported on iOS
header Map<String, String> Uniformly set the headers for network requests within the Mini-Program
headerPriority ConfigPriority Header priority setting. Default is global configuration priority
enableH5AjaxHook Boolean Whether to enable the hook function for H5 pages loaded within the Mini-Program. Default is false. Only supported on iOS. For details, see the comments in the API
h5AjaxHookRequestKey String After enabling enableH5AjaxHook, request hooks will be applied. The requestKey can be set. Only supported on iOS
pageCountLimit int Maximum limit for the page stack within the Mini-Program. Default value is 0, meaning no limit.
schemes List<String> Array of custom schemes. The SDK internally supports WeChat, Alipay, FinClip App, tel schemes by default
debug Boolean Set debug mode, affects debugging and logging.
maxRunningApplet int Set the maximum number of Mini-Programs running simultaneously. Only supported on Android
webViewMixedContentMode int WebView mixed content mode. Only supported on Android
bindAppletWithMainProcess Boolean Whether the Mini-Program process is bound to the main process. Default is false. When set to true, if the App is killed, the Mini-Program closes simultaneously. Only supported on Android
killAppletProcessNotice String Notification text when the Mini-Program is closed after the App is killed. Only supported on Android
enableScreenShot Boolean Whether to allow screenshots and screen recording. Default is true. Only supported on Android
screenShotPriority ConfigPriority Priority setting for the screenshot/screen recording configuration item. Default is GLOBAL. Only supported on Android
logLevel LogLevel Log recording level. Default is NONE.
logMaxAliveSec int Maximum cache time for log files, in seconds. Default is 10 days.
logDir String Directory where log files are saved.
enablePreNewProcess Boolean Whether to create the process in advance. Default is true. Only supported on Android
language LanguageType Language type for the SDK's public UI. Default is Chinese
customLanguagePath String Relative path for the SDK's public UI custom language. Priority is higher than the language property (Only effective on iOS platform)
localeLanguage String Custom language for the SDK. Priority is higher than the built-in language property (Only effective on Android platform). For the language list, refer to: https://uutool.cn/info-i18n/ or the Java class 【java.util.Locale】. Example: Simplified Chinese: zh_CN, Traditional Chinese: zh_TW, English: en
useLocalTbsCore Boolean Whether to use the local TBS core. Default is false. Only supported on Android
tbsCoreUrl String Download address for the TBS core, excluding the file name. Only supported on Android
enableJ2V8 Boolean Whether to enable j2v8. Default is false. Only supported on Android
backgroundFetchPeriod int Time interval for periodic updates (hours). Setting to 0 will not initiate periodic update requests. Acceptable range is 3-12 hours
grayAppletVersionConfigs Map<String, dynamic>? Flutter-specific configuration item, used to pass grayscale extension parameter configurations to the native side (Example configuration see the initialization example above)

# 2.2 Configuration Items in UIConfig

Configuration Name Type Description
navigationTitleTextAttributes Map<String, dynamic> Style of the navigation bar title. Currently only supports font configuration. Only supported on iOS
navigationBarHeight double Navigation bar height. Default is 44. Only supported on iOS
navigationBarTitleLightColor int Light color of the navigation bar title (color under the system dark theme). Default is white 0xffffffff
navigationBarTitleDarkColor int Dark color of the navigation bar title (color under the system light theme). Default is black 0xff000000
navigationBarBackBtnLightColor int Light color of the navigation bar back button (color under the system dark theme). Default is white
navigationBarBackBtnDarkColor int Dark color of the navigation bar back button (color under the system light theme). Default is black
moreMenuStyle int Style of the pop-up menu view 0:Default 1:Normal
isHideBackHomePriority ConfigPriority Priority setting for hiding the navigation bar's back-to-home button. Default is global configuration priority. Only supported on iOS
isAlwaysShowBackInDefaultNavigationBar Boolean When the navigation bar is the default navigation bar, whether to always show the back button. Default is false. Only supported on Android
isClearNavigationBarNavButtonBackground Boolean Whether to clear the background of the navigation bar's navigation buttons. Default is false. Only supported on Android
isHideFeedbackAndComplaints Boolean Hide the 【Feedback and Complaints】 menu in the ... pop-up menu. Default is false
isHideBackHome Boolean Hide the 【Back to Home】 menu in the ... pop-up menu. Default is false
isHideForwardMenu Boolean Hide the 【Forward / Share】 menu in the ... pop-up menu. Default is false
isHideShareAppletMenu Boolean Hide the 【Share】 menu in the ... pop-up menu. Default is true
isHideAddToDesktopMenu Boolean Hide the 【Add to Desktop】 menu in the ... pop-up menu. Default is true
isHideFavoriteMenu Boolean Hide the 【Favorite】 menu in the ... pop-up menu. Default is true
isHideRefreshMenu Boolean Hide the 【Re-enter Mini-Program】 menu in the ... pop-up menu. Default is false
isHideSettingMenu Boolean Hide the 【Settings】 menu in the ... pop-up menu. Default is false
capsuleConfig CapsuleConfig Style configuration for the capsule in the upper right corner. For specific parameters, see the CapsuleConfig table
navHomeConfig NavHomeConfig Style configuration for the back-to-home button. For specific parameters, see the NavHomeConfig table
floatWindowConfig FloatWindowConfig Android floating window style configuration. For specific parameters, see the FloatWindowConfig table. Only supported on Android
authViewConfig AuthViewConfig Authorization dialog style configuration. For specific parameters, see the AuthViewConfig table.
webViewProgressBarColor int Color of the progress bar when loading H5 pages within the Mini-Program
hideWebViewProgressBar Boolean Hide the progress bar when loading H5 pages within the Mini-Program. Default is false
autoAdaptDarkMode Boolean Whether to adapt to Dark Mode. Default is false
appendingCustomUserAgent String Content to append to the userAgent.
transtionStyle TranstionStyle Default animation method when opening a Mini-Program. Default is TranstionStyleUp. Can be set for the following scenarios: 1. Opening a Mini-Program via scheme; 2. Opening a Mini-Program via universal link; 3. Animation method for navigateToMiniprogram. Only supported on iOS
hideTransitionCloseButton Boolean Whether to hide the close button on the Mini-Program loading page. Default is false.
disableSlideCloseAppletGesture Boolean Whether to disable the swipe-to-close Mini-Program gesture. Default is false.
appletText String Default is "Mini-Program". You need to replace the displayed name. For example, set to "Lightweight Application", all places showing "Mini-Program" will change to "Lightweight Application"
loadingLayoutCls String Loading page Class. Only supported on Android
useNativeLiveComponent Boolean Whether to use the built-in live component. Default is false.

# 2.3 Configuration Items in CapsuleConfig (Capsule)

Configuration Name Type Description
capsuleWidth double Width of the capsule
capsuleHeight double Height of the capsule
capsuleRightMargin double Distance from the right border of the capsule to the right border of the screen
capsuleCornerRadius double Corner radius of the capsule
capsuleBorderWidth double Border width of the capsule
capsuleBgLightColor int Light background color of the capsule, used under the system dark theme. Default color android:0x33000000, iOS:0x80ffffff
capsuleBgDarkColor int Dark background color of the capsule, used under the system light theme. Default color android:0x80ffffff, iOS:0x33000000
capsuleBorderLightColor int Light border color of the capsule, used under the system dark theme. Default color 0x80ffffff
capsuleBorderDarkColor int Dark border color of the capsule, used under the system dark theme. Default color 0x26000000
capsuleDividerLightColor int Light divider color inside the capsule, used under the system dark theme. Default color 0x80ffffff
capsuleDividerDarkColor int Dark divider color inside the capsule, used under the system dark theme. Default color 0x26000000
moreLightImage int Light more button image for the capsule. Not yet supported
moreDarkImage int Dark more button image for the capsule. Not yet supported
moreBtnWidth double Width of the more button in the capsule. Height equals width. Android default is 32; iOS default is 20
moreBtnLeftMargin double Left margin of the more button. Android default is 6; iOS default is 12
closeLightImage int Light close button image in the capsule. Not yet supported
closeDarkImage int Dark close button image in the capsule. Not yet supported
closeBtnWidth double Width of the close button in the capsule. Android default is 32; iOS default is 20
closeBtnLeftMargin double Left margin of the close button in the capsule. Android default is 6; iOS default is 12

# 2.4 Configuration Items in NavHomeConfig (Back to Home Button)

Configuration Name Type Description
width double Width of the back-to-home button
height double Height of the back-to-home button
leftMargin double Distance from the left side of the back-to-home button to the left border of the screen. Android default is 8, iOS default is 10
cornerRadius double Corner radius of the back-to-home button. Default is 5
borderWidth borderWidth Border width of the back-to-home button. Android default is 0.75, iOS default is 0.8
borderLightColor int Light border color of the back-to-home button. Default value 0x80ffffff
borderDarkColor int Dark border color of the back-to-home button. Default value 0x26000000
bgLightColor int Light background color of the back-to-home button. Default value 0x33000000
bgDarkColor int Dark background color of the back-to-home button. Default value 0x80ffffff

# 2.5 Configuration Items in AuthViewConfig (Authorization Dialog)

Configuration Name Type Description
appletNameTextSize double Font size of the Mini-Program name. Default is 16
appletNameLightColor int Light color of the Mini-Program name (Light Mode). Default 0xff222222
appletNameDarkColor int Dark color of the Mini-Program name (Dark Mode). Default 0xffd0d0d0
authorizeTitleTextSize double Font size of the authorization title. Default size 17
authorizeTitleLightColor int Light color of the authorization title (Light Mode). Default 0xff222222
authorizeTitleDarkColor int Dark color of the authorization title (Dark Mode). Default 0xffd0d0d0
authorizeDescriptionTextSize double Font size of the authorization description. Default size 14
authorizeDescriptionLightColor int Light color of the authorization description (Light Mode). Default 0xff666666
authorizeDescriptionDarkColor int Dark color of the authorization description (Dark Mode). Default 0xff5c5c5c
agreementTitleTextSize double Font size of the agreement title. Default size 16
agreementTitleLightColor int Light color of the agreement title (Light Mode). Default 0xff222222
agreementTitleDarkColor int Dark color of the agreement title (Dark Mode). Default 0xffd0d0d0
agreementDescriptionTextSize double Font size of the agreement description. Default size 14
agreementDescriptionLightColor int Light color of the agreement description (Light Mode). Default 0xff222222
agreementDescriptionDarkColor int Dark color of the agreement description (Dark Mode). Default 0xffd0d0d0
linkLightColor int Light color of the link (Light Mode). Default 0xff4285f4
linkDarkColor int Dark color of the link (Dark Mode). Default 0xff4285f4
allowButtonLightConfig AuthButtonConfig Allow button configuration (Light Mode). For detailed configuration, see AuthButtonConfig
allowButtonDarkConfig AuthButtonConfig Allow button configuration (Dark Mode). For detailed configuration, see AuthButtonConfig
rejectButtonLightConfig AuthButtonConfig Reject button configuration (Light Mode). For detailed configuration, see AuthButtonConfig
rejectButtonDarkConfig AuthButtonConfig Reject button configuration (Dark Mode). For detailed configuration, see AuthButtonConfig

# 2.6 Configuration Items in AuthButtonConfig (Buttons in the Authorization Dialog)

Configuration Name Type Description
cornerRadius double Corner radius of the button
normalBackgroundColor int Default background color of the button
pressedBackgroundColor int Background color of the button when pressed
normalTextColor int Default text color of the button
pressedTextColor int Text color of the button when pressed
normalBorderColor int Default border color of the button
pressedBorderColor int Border color of the button when pressed

Our default capsule looks like this:

Then, we only need to set it like this to make it rounded:

UIConfig uiconfig = UIConfig();
CapsuleConfig capsuleConfig = CapsuleConfig();
capsuleConfig.capsuleCornerRadius = 16;
uiconfig.capsuleConfig = capsuleConfig;

The effect is as follows:

© FinClip with ❤ , Since 2017