All Products
Search
Document Center

Mobile Platform as a Service:Quick start

Last Updated:Mar 06, 2025

Mriver Tiny App is only provided in the baseline version of mobile PaaS (mPaaS) 10.2.3, and only supports mPaaS native AAR integration. For more information, see About native AAR integration.

Prerequisites

Before you integrate Mriver Tiny App into Android, make sure that you have activated mPaaS and integrated mPaaS using native AAR integration. Please refer to Prerequisites.

Procedure

The procedure of integrating Mriver Tiny App contains the following steps:

  1. Select the baseline.

    1. Add the baseline 10.2.3.

    2. Add the mini program component.

  2. Initialize configuration.

    1. Initialize mPaaS.

    2. Configure mini program signature verification.

    3. Use mPaaS kernel.

  3. Release a mini program.

    1. Enter the mini program backend.

    2. Configure a virtual domain name.

    3. Create a mini program.

    4. Release the mini program.

  4. Start the mini program.

The following section describes each step in details.

Select the baseline

  1. Add the baseline 10.2.3.

    Click mPaaS > Native AAR Integration. In the popup window, click Start Configuration under Integrate/Upgrade Baseline and add the 10.2.3 baseline.

  2. Add the mini program component.

    Install the Mriver Tiny App component through Component Management (AAR) in the project.

Initialize configuration

Initialize mPaaS

Initialize mPaaS using the mPaaS framework (recommended)

  1. Add the following initialization code to Application.

    public class MyApplication extends Application {
        
        @Override
        public void onCreate() {
            super.onCreate();
            // mPaaS initialization
            MP.init(this);    
        }
    }

    For more details, see Initialize mPaaS.

  2. Add the meta configuration to AndroidManifest.xml.

    <meta-data
        android:name="mpaas.init.param"
        android:value="com.xxx.xxx.MriverInitImpl" />
  3. Add com.xxx.xxx.MriverInitImpl to implement MPInitParamManifest.

    import android.content.Context;
    
    import com.mpaas.core.MPInitParam;
    import com.mpaas.mriver.api.init.MriverInitParam;
    
    public class MriverInitImpl implements com.mpaas.MPInitParamManifest {
        @Override
        public MPInitParam initParam(Context context) {
            MriverInitParam mriverInitParam = MriverInitParam.getDefault();
            mriverInitParam.setMriverInitCallback(new MriverInitParam.MriverInitCallback() {
                @Override
                public void onInit() {
                    if (com.alibaba.ariver.kernel.common.utils.ProcessUtils.isMainProcess()) {
                        // 小程序相关配置,比如自定义jsapi,titlebar等
    
                    }
                }
    
                @Override
                public void onError(Exception e) {
    
                }
            });
            return MPInitParam.obtain().addComponentInitParam(mriverInitParam);
        }
    }

Initialize mPaaS using MPInit

Initialize mPaaS by adding the following code to Application.

public class MyApplication extends Application implements MPInitParam.MPCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        // Initializes mPaaS.
        MriverInitParam mriverInitParam = MriverInitParam.getDefault();
        mriverInitParam.setMriverInitCallback(new MriverInitCallback() {
            @Override
            public void onInit() {
                if (com.alibaba.ariver.kernel.common.utils.ProcessUtils.isMainProcess()) {
                    // Configure the Mriver Tiny App, such as customizing jsapi and titlebar.

                }
            }

            @Override
            public void onError(Exception e) {

            }
        });
        MP.init(this, MPInitParam.obtain().setCallback(this).addComponentInitParam(mriverInitParam));
    }
    
    @Override
    public void onInit() {
        // init success
    }
}

Configure mini program signature verification

Mriver Tiny App provides the feature of package signature verification. By default, the signature verification of the debug package and is disabled, and that of the release package is enabled. The signature verification can be controlled by an API.

// Disable signature verification.
MriverResource.disableVerify();

// Enable signature verification, where xx is the public key corresponding to the private key configured in the backend.
MriverResource.enableVerify(MriverResource.VERIFY_TYPE_YES,"xx");
Note

Before you release a mini program, we recommend that you enable signature verification. For specific operations about how to configure mini program signature verification, see Configure Mini Program package.

Configure the interval for requesting a mini program package

mPaaS supports configuring the interval for requesting a mini program package, which can be controlled by an API.

Mriver.setConfig("h5_nbmngconfig", "{\"config\":{\"al\":\"3\",\"pr\":{\"4\":\"86400\","
    + "\"common\":\"864000\"},\"ur\":\"1800\",\"fpr\":{\"common\":\"3888000\"}},"
    + "\"switch\":\"yes\"}");

Here, \"ur\":\"1800\" specifies the global update interval, where 1800 is the default value in seconds. Modify the value to set the interval for requesting a global mini program package. The value ranges from 0 to 86400 seconds, that is, 0 to 24 hours. 0 indicates that the interval is not limited.

Important

Keep other parameters unchanged when possible.

Use mPaaS kernel

The same-layer rendering capability of the mPaaS kernel based on the mini program can improve the experience of embedded WebView, maps, videos and other components. For the integration and application of the mPaaS kernel, please refer to Integrate mPaaS kernel.

Release a mini program

Before you start a mini program, you must release the mini program in the mPaaS console. Perform the following steps:

  1. Enter the mini program backend. Log on to the mPaaS console, and select the target app. In the left-side navigation pane, choose Mini Program > Mini Program Release.

  2. Configure a virtual domain name. To configure a virtual domain name for the first time, choose Mini Program > Mini Program Release > Manage configuration. The virtual domain name can be any of your domain names. We recommend that you use your enterprise domain name, such example.com.

  3. Create a mini program. Log on to the mPaaS console and perform the following steps:

    1. In the left-side navigation pane, choose Mini Program > Mini Program Release.

    2. On the mini program list page, click Create.

    3. In the Create Mini Program window, enter the mini program ID and name, and then click OK. The mini program ID is a 16-digit number, for example 2018080616290001.

    4. On the mini program list, find the new mini program, and click Add.

    5. In the Basic information section, set the following parameters:

      • Version: Enter the version number of the mini program package, for example 1.0.0.0.

      • Client version range: Select the applicable Android client version range for the mini program. Only the client app within the range can start the mini program. The minimum version can be 0.0.0 while the maximum version can be left empty, indicating that the mini program can start regardless of the client version.

        Note

        Enter the version of the Android client, not that of the mini program.

      • Icon: Click Select file to upload the icon of the mini program package. The icon is required when you create a mini program package for the first time. Sample icon: 6

      • File: Upload the resource file of the mini program package, which must be a .zip file. Here is an mPaaS mini program demo (click here to download), and you can upload it directly.

        Note

        Before you upload it, rename the zip file and its folder to the 16-digit ID of your mini program.

    6. In the Configuration information section, set the following parameters:

      • Entry URL: Required. It is the homepage of the mini program. The format is /index.html#xxx/xxx/xxx/xxx, where xxx/xxx/xxx/xxx following # is the first value under pages in app.json. The entry of the mPaaS mini program demo is /index.html#page/tabBar/component/index.

      • For other parameters, retain the default values.

    7. Check I confirm that the information provided is true and correct.

    8. Click Submit.

  4. Release the mini program. Log on to the mPaaS console and perform the following steps:

    1. In the left-side navigation pane, choose Mini Program > Mini Program Release > Mini Program Official Package Management.

    2. On the mini program list page, select the target mini program and version, and click Create release task.

    3. In the Create release task section, set the following parameters:

      • Release type: Select Official.

      • Release description: Optional.

      Click OK to create the release task.

Start the mini program

After the preceding steps, you can execute the following code in your Android project to start the mini program demo.

Mriver.startApp("2018080616290001");
Note

The 2018080616290001 in the code refers to the mini program ID. The ID here is for reference only, so enter the actual program ID.