openUrl

The openUrl API is called by the super app to open a mini program with its URL.

Method signature

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

Request parameters

Field

Data type

Required

Description

url

string

Yes

The scheme URL of the mini program. The URL should use the HTTP or HTTPs protocols and include the _ariver_appid, _ariver_path, and _ariver_version query string parameters.

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 { openUrl } from 'iapminiprogram-rn';

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

function openMiniUrl(url: string) {
    openUrl(url, {
      success: (success: BaseSuccess) => {
        
      },
      error: (error: BaseError) => {
        
      },
    });
  }