tencent cloud

Opening Mini Programs
Last updated: 2025-08-07 17:57:29
Opening Mini Programs
Last updated: 2025-08-07 17:57:29

Open a mini program

When opening the mini program, the system will check whether there is a locally cached one. If not, it will automatically download the mini program from the remote server and then open it. If a cached version is available, the local mini program will be opened first while the system checks in the background for any new versions on the server.
Note:
If a new version is available, it will be downloaded, and the next time you open the mini program, the updated version will be used.
// Open the mini program using the mini program appid

// @param appID Mini program appid
// @param verType The version type of the mini program to open
// @param scene Scene value
// @param firstPage The first page of the mini program to open
// @param paramsStr The parameter used to open the mini program
// @param parentVC The view controller from which to present the scan view controller
// @param completion Error callback
- (void)startUpMiniAppWithAppID:(NSString *)appID
verType:(TMAVersionType)verType
scene:(TMAEntryScene)scene
firstPage:(NSString * _Nullable)firstPage
paramsStr:(NSString * _Nullable)paramsStr
parentVC:(UIViewController *)parentVC
completion:(void (^)(NSError * _Nullable))completion;
Supported parameters for options:
Name
Required
Type
Description
appid
True
NSString
The appid of the mini program to open.
verType
True
TMAVersionType
The type of the mini program to open.
scene
True
TMAEntryScene
The scene value for opening the mini program.
firstPage
False
NSString
The first page of the mini program to open.
paramsStr
False
NSString
The parameters to pass when opening.
parentVC
True
UIViewController
The view controller from which to present the scan view controller.
completion
True
block
Error callback.

Open a mini program by mini program appid

To open the released version of a mini program :
[[TMFMiniAppSDKManager sharedInstance] startUpMiniAppWithAppID:appId parentVC:self completion:^(NSError * _Nullable error) {
NSLog(@"open applet error:%@",error);
}];
Note:
The appid is the ID of the mini program, which can be obtained from the mini program developer or via the mini program search API.
To preview or open the development version of a mini program:
[[TMFMiniAppSDKManager sharedInstance] startUpMiniAppWithAppID:appId verType:verType scene:TMAEntrySceneAIOEntry firstPage:nil paramsStr:nil parentVC:self completion:^(NSError * _Nullable error) {
NSLog(@"open applet error:%@",error);
}];
Note:
The appVerType should match the version of the mini program. The value of the appVerType can be obtained from the TMFAppletSearchInfo object instance returned by the API (getRecentList).
The value of appVerType for the mini program preview should be TMAVersionPreview.
The value of appVerType for the development version of the mini program should be TMAVersionDevelop.

Scan the QR code to open a mini program

The mini program SDK provides a capability to open the mini program by scanning the QR code. You need to integrate the extension library TCMPPExtScanCode before scanning the QR code.
// Scan the QR code to open the mini program
// @param parentVC The view controller from which to present the scan view controller
// @param completion Error callback
- (void)startUpMiniAppWithQRCodeWithParentVC:(UIViewController *)parentVC
completion:(void (^)(NSError * _Nullable))completion;

Open a mini program through QR code

The mini program SDK provides an API to open mini programs based on QR code scanning. Before using the scanning capability provided by the mini program SDK, you need to integrate the scanning extension capability. For details about the integration, refer to the scanning capability documentation.
After integrating the scanning capability, you can start the QR code scanning and open the mini program as follows:
/// Open a mini program via the QR code
/// @param qrData QR code content
/// @param parentVC The view controller from which to present the scan view controller
/// @param completion Error callback
- (void)startUpMiniAppWithQrData:(NSString *)qrData
parentVC:(UIViewController *)parentVC
completion:(void (^)(NSError * _Nullable error))completion;

Open the released version of a mini program through QR code

Starting from version 2.0.9, the QR code for the released version of a mini program can be generated and modified in the console. Once the superapp scheme is configured, you can open the mini program by scanning the QR code with the system camera.
Go to Superapp management - Mini program approval - Available in the console, click Download QR code in the Operation column, and the following pop-up appears:



The default scheme is tcmpp plus last few characters of the appid, which can be found through Superapp management - Superapp list.



The client needs to return the scheme protocol name via the getAppScheme delegate method. Example code:

- (NSString *)getAppScheme{
return @"tcmpp";
}
In the main project's info.plist file, configure the same scheme under URL Types:



Implement the handleOpenUrl method in the openUrl method. See the example below:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
if ([[TMFMiniAppSDKManager sharedInstance] handleOpenUrl:url]){
return YES;
}
return YES;
}
Once completing the above steps, you can scan the QR code in the console with the system camera to open the released version of the mini program.

Open a mini program by specified startup options

Note:
Supported in version 2.2.10 and later
The mini program can be started up by specified startup options.
// Start up the mini program by the startup options

// @param appID The appid of the mini program to start up
// @param options The options for starting the mini program
// @param parentVC The parent view controller
// @param completion The completion block
- (void)startUpMiniAppWithAppID:(NSString *)appID
options:(TMAStartUpOptions *)options
parentVC:(UIViewController *)parentVC
completion:(void (^)(NSError * _Nullable))completion;
TMAStartUpOptions List of supported options:
Name
Type
Default value
Description
verType
TMAVersionType
TMAVersionOnline
The type of the mini program to open.
scene
TMAEntryScene
TMAEntrySceneAIOEntry
The scene value for opening the mini program.
firstPage
NSString
nil
The first page of the mini program to open.
paramsStr
NSString
nil
The parameters to pass when opening.
forceUpdate
BOOL
NO
Whether to enforce checking for the latest version.


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback