Alipay+ DocsAlipay+ Docs

getDeviceTokenOnCurrentDevice

Call the getDeviceTokenOnCurrentDevice API to retrieve the device token of the current device.

Method signature

copy
public static func getDeviceTokenOnCurrentDevice(completion: @escaping (Result<IAPAPDeviceToken?, IAPAPErrors>) -> Void)

Request parameters

Parameter

Type

Required

Description

completion

(Result<IAPAPDeviceToken?, IAPAPErrors>) -> Void

Yes

An asynchronous completion callback that returns the result of calling the getDeviceTokenOnCurrentDevice API.

IAPAPDeviceToken

Parameter

Type

Required

Description

tokenUniqueReference

String

Yes

The unique identifier to identify a device token.

primaryAccountIdentifier

String

Yes

An opaque value that identifies the primary account number that funds the device token's transactions.

primaryAccountNumberSuffix

String

Yes

A display-ready version of the primary account number.

deviceAccountIdentifier

String

Yes

The unique identifier for the device-specific account number.

deviceAccountNumberSuffix

String

Yes

A display-ready version of the device-specific account number.

passActivationState

IAPAPDeviceTokenState

Yes

The activation status of the device token.

devicePassIdentifier

String

No

An opaque value for the device token.

pairedTerminalIdentifier

String

No

The unique identifier to identify the paired terminal.

IAPAPDeviceTokenState

Value

Code

Description

unknown

-1

Unknown status.

activated

0

The token is activated.

requiresActivation

1

The token requires activation.

activating

2

The token is in activation process.

suspended

3

The token is suspended.

deactivated

4

The token is deactivated.

Response parameters

N/A

Sample

copy
IAPApplePay.getDeviceTokenOnCurrentDevice { result in
    switch result {
    case .success(let deviceToken):
        print("getDeviceTokenOnCurrentDevice success: \(String(describing: deviceToken))")
    case .failure(let error):
        print("getDeviceTokenOnCurrentDevice error: \(error)")
    }
}