Skip to content

Quickstart(iOS)

This topic introduces how to quickly set up the iOS MiniProgram SDK and implement basic mini-program capabilities.

Get started

To get started with MiniProgram SDK, perform the following actions:

Step 1: Get SDK Key and SDK SECRET

Log in to FinClip Mini Program Platform, go to the App Manage page, create an application, then click to add Bundle ID, enter your project bundle id. After the creation is complete, You can find SDK KEY,SDK SECRET of the application will be generated.

Step 2: Update your podfile

Add dependency to your Podfile with the following code:

objective-c
platform :ios, "9.0"

inhibit_all_warnings!

target "YOUR_TARGET" do
    pod 'FinApplet'
end

Step 3: Install the SDK

To install the SDK, run the pod install or pod install --repo-update command at the path of your Podfile.

Step 4: Initialize the SDK

To initialize the SDK, frist import header file like this #import <FinApplet/FinApplet.h>, then use the following code:

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"];
    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];

Nota that the code is recommended to be inserted in - (BOOL)application:(UIApplication _)application didFinishLaunchingWithOptions:(NSDictionary _)launchOptions and needs to be run on the main thread.

Step 5. Update Information Property List

Mini-progarm will access certain protected resources, like the camera, or the user’s photos, the system asks the user for permission on behalf of your app. To signal that your app needs the access, you add a UsageDescription key to your app’s Information Property List.

access
UsageDescription key
access to the photo libraryNSPhotoLibraryUsageDescription
add-only access to the photo libraryNSPhotoLibraryAddUsageDescription
CameraNSCameraUsageDescription
microphoneNSMicrophoneUsageDescription

Step 6: Open a mini-program

To open a mini-program in your app, use the following APIs:

objective-c
FATAppletRequest *request = [[FATAppletRequest alloc] init];
request.appletId = @"your mini-program id";
request.apiServer = @"your server";
request.transitionStyle = FATTranstionStyleUp;
request.startParams = startParams;

[[FATClient sharedClient] startAppletWithRequest:request InParentViewController:self completion:^(BOOL result, FATError *error) {
    NSLog(@"open mini-progarm:%@", error);
} closeCompletion:^{
    NSLog(@"close mini-progarm");
}];