openApp

The openApp API is called by the super app to open a mini program with its unique ID.

Method signature

copy
function openApp(
  appId: string,
  extra?: {
    extraParams?: Map<string, any>;
    success?: (success: BaseSuccess) => void;
    error?: (error: BaseError) => void;
  }
)

Request parameters

Field

Data type

Required

Description

appId

string

Yes

The unique ID that is assigned by Mini Program Platform to identify a mini program. You can get the ID under the Mini Programs menu from the Mini Program Platform console.

extra

Object

No

An extended attribute that is used to provide additional information if necessary. The included parameters are:

  • error: OptionalThe callback that is executed upon failure to open the mini program. When executed, it receives an instance of BaseError object. Specify this parameter if you need to handle the encountered errors.
  • success: OptionalThe callback that is executed upon successful opening of the mini program. When executed, it receives an instance of BaseSuccess object. Specify this parameter if you need to handle successful operations.
  • extraParams: OptionalThis parameter is used to pass startup parameters to the IAPMiniProgram SDK to customize the behavior of a mini program during startup. Specify this using key-value pairs where the key is a string and the value can be any data type.

Response parameters

N/A

Result codes

Result code

Result message

Description

Further action

1000

SUCCESS

The SDK opens the mini program successfully.

N/A

2000

The result message varies depending on the error that occurs.

The SDK encounters an error when attempting to open the mini program.

Refer to the result message for specific actions.

Sample

copy
import { openApp } from 'iapminiprogram-rn';
import type { BaseSuccess, BaseError } from 'iapminiprogram-rn';

  function openMiniApp(appId: string) {
    openApp(appId, {
      success: (success: BaseSuccess) => {
        
      },
      error: (error: BaseError) => {
       
      },
    });
  }