Alipay+ DocsAlipay+ Docs

connect

Call the connect API to associate the SDK with the signed-in user.

Method signature

copy
public synchronized boolean connect(@NotNull String id, @Nullable ACResultCallback<Boolean> callback)

Request parameters

Item

Type

Description

Required

id

String

The ID used internally by the SDK for user isolation. The SDK recognizes identical IDs passed through the connect API as the same user. Avoid using the original MPP user ID (UID).

The SDK will not persistently store the ID.

Yes

callback

ACResultCallback

Callback mechanism for handling scenarios with extended connection times.

If not specified, no callback occurs.

No

Response parameters

Item

Type

Description

Required

result

Boolean

Whether it is successfully connected.

Callback does not affect the result.

Yes

Overload

Use this overload to supply a contactless spending limit level at connection time.

Note: Before using this overload, import com.iap.android.nfc.model.ConnectParams.

Item

Type

Description

Required

id

String

The ID used internally by the SDK for user isolation. The SDK recognizes identical IDs passed through the connect API as the same user. Avoid using the original MPP user ID (UID).

The SDK will not persistently store the ID.

Yes

amountLevel

String

The contactless spending limit level for this connection. When provided, this value overrides the amountLevel set in APNFCConfig in the init API. Pass a positive integer as a string value.

No

Sample

copy
public synchronized boolean connect(@NotNull ConnectParams connectParams, @Nullable ACResultCallback<Boolean> callback)

Sample

copy
boolean connected = manager.connect(currentUid, (result, errorCode, errorMsg) -> {
    if (Boolean.TRUE.equals(result)) {
        log("Connect success");
    } else {
        log("Connect failed");
    }
});