openReactNativePage

The openReactNativePage API is used to open a React Native page in a mini program. This allows the React Native page to be displayed even if it is initially covered by the mini program. After opening the page, you can call the handlePageResult API to close the page.

Note: This interface is applicable to all versions of IAPMiniProgram SDK 1.2.0 and later. For more information, see the SDK release notes.

Method signature

copy
function openReactNativePage(
  data: OpenPageRequest,
  extra?: {
    success?: (success: BaseSuccess) => void;
    error?: (error: BaseError) => void;
  }
)

Parameters

Parameter

Data type

Required

Description

data

OpenPageRequest

Yes

An object that is used to specify request parameters to open the React Native page.

extra

Object

No

An object that is used to provide additional information if necessary. The object can contain the following callbacks:

  • error: The callback that is executed upon failed opening of the React Native page.
  • success: The callback that is executed upon successful opening of the React Native page.

OpenPageRequest

Parameter

Data type

Required

Description

extendedInfo

Object

No

An extended attribute that is used to provide additional information if necessary.

bundleURLPath

String

No

The URL path of the bundled file. It specifies the location from which resources are loaded. If specified, the new React Native bridge is used to open the page. Otherwise, the original React Native bridge is used.

moduleName

String

Yes

The name of the native module that signifies the JavaScript bundle loaded as the starting point.

jsMainModulePath

String

No

The path of the main JavaScript entry file.

extra

Parameter

Data type

Required

Description

error

BaseError

No

The callback that is executed upon failure to call this API.

success

BaseSuccess

No

The callback that is executed upon success to call this API.

Error codes

Error code

Code name

Error message

Further action

2000

The displayed code name 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.

Samples

Parameters not included

copy

import { openReactNativePage } from 'iapminiprogram-rn';

function openPageApp() {

    const req: OpenPageRequest = {
      moduleName: 'RNPage',
    };
    openReactNativePage(req);
  }
}

Parameters included

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


function openPageApp() {

    let extdata = {
      a: 'a',
      b: 'b',
      c: {
        c1: 'c1',
        c2: 'c2',
      },
    };

    const req: OpenPageRequest = {
      moduleName: 'RNPage',
      extendedInfo: extdata,
    };
    openReactNativePage(req, {
      success: (success: BaseSuccess) => {
      },
      error: (error: BaseError) => {
      },
    });
  }
}