init() method

Based on business requirements, choose an appropriate location to initialize the IAPMiniProgram SDK by using the init() method.

Sample code

copy
void initSDK() async {
 bool initResult = await IAPMiniProgram.instance.init(
        oauthService: TestOAuthService(),
        paymentService: TestPaymentService(),
        memberInfoService: TestMemberInfoService(),
        codeService: TestCodeService(),
        openId: '111',
        apiKeyForGoogleMaps: 'xxxxx',
        customUserAgent: 'ua',
        env: 'prod', // test prod sit
        appEventListener: TestAppEventListener());
  }

Parameters

Parameter

Required

Data type

Description

oauthService

No

method

See OAuthService

paymentService

No

method

See PaymentService

memberInfoService

No

method

See MemberInfoService

codeService

No

method

See CodeService

openId

No

method

See setOpenId

apiKeyForGoogleMaps

No

String

Indicates the Google API key that is required for using Google Maps. To get a Google API key, see Using API Keys in Google's documentation.

For more information, see Google Map SDK component.

customUserAgent

No

String

Indicates a customized user agent.

env

No

String

Indicates a customized SDK environment name, for example, "prod" is used to indicate the production environment.

appEventListener

No

API

Listens for the mini-program lifecycle events.