tencent cloud

Feedback

Opening mini programs

Last updated: 2024-07-03 18:01:01

    Opening mini programs

    When opening a mini program, the system first checks if there is a cached version locally. If not, it will automatically download the mini program from the remote server and then open it. If a cached version exists, it will open the local version while checking for updates in the background. If a new version is available, it will be downloaded and used the next time the mini program is opened.
    Note:
    If a new version is available, it will be downloaded and used the next time the mini program is opened.
    // Opening a mini program through the mini program ID
    // Open the mini program through the mini program id
    // @param appID Mini program ID - Mini program ID
    // @param verType Specify the mini program type  - The version type of mini program to open
    // @param scene Scene value - scene value
    // @param firstPage Open pages - open the page
    // @param paramsStr Bring in parameters -  brings in parameters
    // @param parentVC Which vc to call from - Which vc to call from
    // @param completion Wrong callback - 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;etion;
    Parameters supported by `options`:
    Name
    Required
    Type
    Description
    appID
    Yes
    NSString
    The mini program ID to open
    verType
    Yes
    TMAVersionType
    The type of mini program to open
    scene
    Yes
    TMAEntryScene
    The scene value for opening the mini program
    firstPage
    No
    NSString
    The page to open
    paramsStr
    No
    NSString
    The parameter used to open a page
    parentVC
    Yes
    UIViewController
    The view controller to call from
    completion
    Yes
    block
    Wrong callback

    Opening a mini program by mini program ID (appId)

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

    Opening a mini program through QR code

    The mini program SDK provides an API to open mini programs based on platform QR code. Before using the scanning capability provided by the mini program SDK, you need to integrate the scanning extension capability. Refer to the scanning capability support documentation for integration details.
    After integrating the scanning capability, you can start QR code scanning and open the mini program as follows:
    /// Open mini program using QR code
    /// @param qrData QR code content
    /// @param parentVC Which vc to call from
    /// @param completion Wrong
    - (void)startUpMiniAppWithQrData:(NSString *)qrData
                          parentVC:(UIViewController *)parentVC
                         
    completion:(void (^)(NSError * _Nullable error))completion
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support