Skip to content

SDK Initialization

Before using the API of the mini progmini, you need to initialize the mini progmini SDK. only after the SDK is successfully initialized, you can use the API provided by the SDK, otherwise the API calls will fail.

1. Initialization

There are two APIs to initialize the SDK:

objective-c
/// Initialize the SDK
/// @param config Configure the object
/// @param error The error returned when initialization fails
- (BOOL)initWithConfig:(FATConfig *)config error:(NSError **)error;

/// Initialize the SDK
/// @param config Configure the object
/// @param uiConfig UI configuration object
/// @param error The error returned when initialization fails
- (BOOL)initWithConfig:(FATConfig *)config uiConfig:(FATUIConfig *)uiConfig error:(NSError **)error;

Example initialization:

objective-c
FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init];
storeConfig.sdkKey = @"Fill in the SDK key here";
storeConfig.sdkSecret = @"Fill in the SDK secret here";
storeConfig.apiServer = @"Fill in your server address here"; // 例如:https://api.finclip.com;
FATConfig *config = [FATConfig configWithStoreConfigs:@[storeConfig]];

[[FATClient sharedClient] initWithConfig:config error:nil];

note

  1. Starting from version 2.13.109, the FinClip mini progmini SDK supports configuring multiple server information, so that you can open the mini progmini on server A and the mini progmini on server B, so we provide a way to configure multiple server information.
  2. 'configWithAppSecret:appKey:' will be deprecated in the future, please replace FATConfig with 'configWithStoreConfigs' as soon as possible.
  3. As of 2.34.1, apiPrefix no longer needs to be configured, and apiPrefix is already configured internally on the interface.

The following is an example of configuring multiple server initialization SDKs:

objective-c
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"servers" ofType:@"plist"];
NSArray *array = [NSArray arrayWithContentsOfFile:plistPath];
NSMutableArray *storeArrayM = [NSMutableArray array];
for (NSDictionary *dict in array) {
    FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init];
    storeConfig.sdkKey = dict[@"sdkKey"];
    storeConfig.sdkSecret = dict[@"sdkSecret"];
    storeConfig.apiServer = dict[@"apiServer"];
    storeConfig.apmServer = dict[@"apmServer"];
    if ([@"SM" isEqualToString:dict[@"cryptType"]]) {
        storeConfig.cryptType = FATApiCryptTypeSM;
    } else {
        storeConfig.cryptType = FATApiCryptTypeMD5;
    }

    [storeArrayM addObject:storeConfig];
}
FATConfig *config = [FATConfig configWithStoreConfigs:storeArrayM];
[[FATClient sharedClient] initWithConfig:config error:nil];

2. Configuration items

The configuration items when initializing the SDK are 'FATConfig' and 'FATUIConfig'. 'FATConfig' is mainly related to the UI does not want to deal with configuration items; The 'FATUIConfig' is mainly UI-related configuration items.

2.1 Configuration items in FATConfig

Configuration nameConfiguration description
currentUserIdThe current user is uniquely identified, and the mini progmini cache information is stored in a different directory named with userId
disableAuthorizeWhether to disable the SDK from triggering permission requests, the default is NO, if set to YES, APIs that use permissions in the SDK will not actively apply for permissions.
appletAutoAuthorizeWhether to automatically apply for permissions from the SDK, the default is NO, a dialog box will pop up to let users confirm whether to allow the request, and if set to YES, automatically apply for permissions from the SDK
disableGetSuperviseInfoWhether to disable the SDK Regulatory Interface API, default is NO, if set to YES, the SDK disables the Regulatory Interface API (getSuperviseInfo)
appletIntervalUpdateLimitThe number of Mini Programs that are automatically checked for updates in the background, and the value range is 0~50. 0 means do not check for updates; Do not set the default to 3.
startCrashProtectionWhether to enable crash prevention. UnrecognizedSelector, KVO, Notification, Timer, Container (array out of bounds, dictionary inserts nil, etc.), String (out of bounds, nil, etc.)
enableApmDataCompressionWhether to compress data when APM data is reported
encryptServerDataWhether the data returned by the platform interface is to be encrypted
enableAppletDebugWhether to enable global debug mode, all mini programs will display vconsole after setting it to YES, and if it is set to NO, the development version, trial version, and IDE preview version can enable debug mode through the More menu
enableH5AjaxHookWhether to enable the H5 page hook function loaded in the Mini Program is not required. See the comments in the API for details
h5AjaxHookRequestKeyAfter enabling H5AjaxHook is enabled, a request request will be hooked, and the requestKey can be set
pageCountLimitThe maximum limit of the page stack in the mini progmini. The default value is 0, which means no limit.

2.2 Configuration items in FATUIConfig

Configuration NameConfiguration Description
navigationTitleTextAttributesThe style of the navigation bar title, currently only supports the configuration of fonts.
capsuleConfigThe style configuration of the upper right capsule, see the FATCapsuleConfig table for specific parameters
navHomeConfigStyle configuration for the configuration of the Back Home button, see the FATNavHomeConfig table for specific parameters
navigationBackImageImage object for the navigation bar back button
progressBarColorProgress bar color when loading links in the WebView component of the mini progmini
moreMenuStyleCapsule more button pop-up menu view style
hideForwardMenuWhether to hide the forward button in the More menu.
hideSettingMenuWhether to hide the Settings button in the More menu of the Mini Program.
hideFeedbackMenuWhether to hide the Complaint feedback button in the More menu.
hideRefreshMenuWhether to hide the reentrancy button in the More menu.
hideBackToHomeWhether to hide the Back to Home button in the navigation bar.
autoAdaptDarkModeWhether it is suitable for dark mode.
appendingCustomUserAgentYou need to add content to the userAgent.
appletTextThe default is "Mini Program", and you need to replace the name of the display. For example, the settings will be "light application", and all places where "mini programs" are displayed will become "light application"
transtionStyleThe default animation method when opening the mini progmini. When not set, the default is FATTranstionStyleUp. You can set the following scenarios::1. Scheme opens the mini progmini;2. Universal Link opens the mini progmini;3. The way navigateToMiniprogram is animated
hideTransitionCloseButtonWhether to hide the close button for the transition page. The default is NO
disableSlideCloseAppletGestureWhether to disable the gesture of sliding over to close the mini progmini. The default is NO

2.3 Configuration items in FATCapsuleConfig (capsule).

| Configuration Name | Configuration Description | | ------------------------ | --------------------------------------------------------------------------- | --------------------------------------------- | ------------------ | ------------------ | ------------------ | | capsuleWidth | The width of the capsule | | capsuleHeight | the height of the capsule | | capsuleRightMargin | the distance of the capsule's right frame from the right side of the screen | | capsuleCornerRadius | the radius of the capsule's corners | | capsuleBorderWidth | the width of the capsule's border | | capsuleBorderLightColor | the capsule's light border color | | capsuleBorderDarkColor | the capsule's dark border color | | capsuleBgLightColor | the capsule's light background color | | capsuleBgDarkColor | capsuleBgDarkColor | capsuleBgDarkColor | capsuleBgDarkColor | capsuleBgDarkColor | capsuleBgDarkColor | | moreLightImage | Capsule's lighter more button image | | capsuleBgDarkImage | capsuleBgDarkColor | capsuleBgDarkColor | | moreBtnWidth | moreBtnWidth | the width of the capsule's more buttons | | moreBtnLeftMargin | moreBtnLeftMargin | the left margin of the button | | closeLightImage | The dark close button image of the capsule | | closeDarkImage | The image of the dark close button in the capsule. | | closeBtnWidth | The width of the close button in the capsule. | | closeBtnLeftMargin | The left margin of the close button in the capsule. | | capsuleDividerLightColor | capsuleDividerLightColor | the color of the light divider in the capsule | | capsuleDividerDarkColor | The color of the dark divider in the capsule. |

2.4 Configuration items in FATNavHomeConfig (Back to Home button)

Configuration NameConfiguration Description
widthReturns the width of the home button
heightReturns the height of the home button.
leftMarginReturns the distance of the left side of the home button from the left border of the screen.
cornerRadiusreflects the corner radius of the home button.
borderWidthReturns the border width of the home button.
lightImageReturns the light image of the home button.
darkImageReturns the dark button image of the home button.
borderLightColorReturns the light border color of the home button.
borderDarkColorReturns the dark border color of the home button.
bgLightColorReturns the light background color of the home button.
bgDarkColorReturns the dark background color of the home button.

Our default capsule looks like this:

Then, we just need to set it up like this to make it rounded corners.

objective-c
FATUIConfig *uiConfig = [[FATUIConfig alloc] init];
uiConfig.capsuleConfig.capsuleCornerRadius = 15.5;

The effect is as follows: