openApp

The openApp API is called by the super app to open mini programs with appId, the unique ID of the mini program.

Method signature

copy
void openApp(Context context, String appId, Bundle extraParams, GriverContainerAPICallBack callBack) 

Request parameters

Field

Data type

Description

Required

context

Context

Interface to global information about an application environment.

M

appId

String

The unique ID that is assigned by Mini Program Platform to identify a mini program. You can get the ID from the Mini Program Platform console or by fetching mini program information with the fetchApps API.

M

extraParams

Bundle

This parameter is used to pass startup parameters to IAPMini Program SDK to customize the behavior of a mini program during startup. The passed parameters should be included in the definition of {@linkGriverParams.LaunchParams}. For how to specify the startup parameters, see Startup parameters.

O

callBack

GriverContainerAPICallBack

The callback that is used to listen to mini program launch failures.

O

Response parameters

Field

Data type

Description

Required

error

Error

An object that is used to return the error code and error message when the mini program launch fails.

O

Error codes

Error code

Error message

Description

Further action

90002

GRV_CONTAINER_NOT_INITIALIZED

IAPMiniProgram SDK is not initialized.

Initialize the SDK.

90003

GRV_CONTAINER_ERROR_UNKNOWN

Parameter error.

Refer to the Request parameters table and check if all parameter types are correct and if all required parameters are specified.

Sample

Kotlin

copy
val bundle = Bundle()
bundle.putString("query", "a=b&c=d")
Griver.openApp(context, appId, bundle,
               GriverContainerAPICallBack { errorCode, errorMessage ->
                   //return the error code and error message if the mini program launch fails
               })

Java

copy
Bundle bundle = new Bundle();
bundle.putString("query", "a=b&c=d");
Griver.openApp(context, appId, bundle, new GriverContainerAPICallBack() {
    @Override
    public void error(int errorCode, String errorMessage) {
        //return the error code and error message if the mini program launch fails
    }
});