tencent cloud

Feedback

Opening the Mini-Program

Last updated: 2024-03-04 22:40:23

    Mini Program Version Types

    There are four types of Mini Program versions:
    Official Version: This version is available for public use. Anyone can access it by scanning the QR code.
    Development Version: This is the version used for development and debugging.
    Preview Version: This is the version for preview and examination.
    Experience Version: This is the beta testing version.

    Open the Mini Program

    Upon opening the Mini Program, the system first checks whether there is a cached version of the Mini Program locally. If not, it will automatically download the Mini Program from the remote server and then launch it. If a cached version exists, the local Mini Program will be launched first, while the backend simultaneously verifies whether a newer version exists on the server.
    Note:
    Should a newer version be available, the system will download the updated Mini Program. Consequently, the next time the Mini Program is launched, the updated version will be utilized.
    /**
    * Launching the Official Version (Already Online) of the Mini Program
    * @param activity
    * @param appId
    * @param options
    */
    public static void startMiniApp(Activity activity, String appId, MiniStartOptions options)
    
    /**
    * Initiating the Preview/Development Version of the Mini Program
    * Note: If preview/development version information already exists locally (as indicated by the getRecentList returning a list of existing Mini Program), this method can be used to launch it. Otherwise, the startMiniAppByLink method must be used to scan a QR code for access.
    *
    * @param activity
    * @param appId
    * @param scene Set different parameters when launching the Mini Program under various scenarios. See MiniScene for details.
    * @param appVerType The version type of the Mini Program(Preview/Development Version), refer to MiniApp for details.
    * @param options
    */
    public static void startMiniApp(Activity activity, String appId, int scene, int appVerType, MiniStartOptions options) {
    Launching the Official Version of the Mini Program
    The following method is used to launch the latest online version of the Mini Program.
    TmfMiniSDK.startMiniApp(this, appId, options);
    Launching the Preview and Development Versions of the Official Mini Program
    If preview/development version information already exists locally (as indicated by the getRecentList returning a list of existing Mini Programs), this method can be used to launch it. Otherwise, use the QR code scanning feature of startMiniAppByLink to launch it.
    Note:
    Set the appVerType parameter in the startMiniApp method.
    TmfMiniSDK.startMiniApp(this, appId, MiniScene.LAUNCH_SCENE_MAIN_ENTRY, appVerType, options);
    Opening the Mini Program from Search Results
    Open the Mini Program from the list returned by searching the TmfMiniSDK.searchMiniApp interface.
    TmfMiniSDK.startMiniApp(this, appId, MiniScene.LAUNCH_SCENE_SEARCH, MiniApp.TYPE_ONLINE, options);
    The miniStartOptions.resultReceiver can be used to receive error messages when launching the Mini Program. Therefore, the returned error codes can be referenced in MiniCode, which provides corresponding explanations.
    private ResultReceiver mResultReceiver = new ResultReceiver(new Handler()) {
    @Override
    protected void onReceiveResult(int resultCode, Bundle resultData) {
    if (resultCode != MiniCode.CODE_OK) {
    String errMsg = resultData.getString("errMsg");
    Toast.makeText(mActivity, errMsg + resultCode, Toast.LENGTH_SHORT).show();
    }
    }
    };

    Launch the Mini Program via QR Code.

    TMF incorporates a built-in scanning module, which is initiated through the scan interface. The scan results are processed in onActivityResult by calling the scanResult.
    /**
    * Initiate Scanning
    *
    * @param activity
    */
    public static void scan(Activity activity)
    /**
    * Retrieve Scan Results
    *
    * @param requestCode
    * @param intent
    * @return
    */
    public static JSONObject getScanResult(int requestCode, Intent intent)
    /**
    * Launching the Mini Program via scanning, non-TMF Mini Program QR codes will result in an error.
    *
    * @param activity
    * @param link
    * @param resultReceiver Receives error instances during the Mini Program launch process.
    */
    public static void startMiniAppByLink(Activity activity, String link,
    MiniStartLinkOptions resultReceiver)
    
    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