Alipay+ DocsAlipay+ Docs

activateDeviceToken

Call the activateDeviceToken API to activate a device token. Ensure you complete identity verification before calling this method.

The parameters for this method originate from:

  1. The redirect URL when selecting in-app verification
  2. Activating an inactive device token within the app

In the redirect scenario, you need to parse the URL that redirects to your MPP app, extract the deviceAccountIdentifier and redirect_url from the query parameters, and then pass them to this API.

Method signature

copy
public static func activateDeviceToken(deviceAccountIdentifier: String, redirectUrlStr: String?, completion: @escaping (Result<Bool, IAPAPErrors>) -> Void)

Request parameters

Parameter

Type

Required

Description

deviceAccountIdentifier

String

Yes

The parameter in the redirect link from Apple Wallet.

redirectUrlStr

String

No

The redirect link from Apple Wallet.

completion

(Result<Bool, IAPAPErrors>) -> Void

Yes

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

Response parameters

N/A

Sample

copy
IAPApplePay.activateDeviceToken(deviceAccountIdentifier: "mock_deviceAccountIdentifier", redirectUrlStr: "example://path") { result in
    switch result {
    case .success(let isSuccess):
        print("activateDeviceToken success: \(isSuccess)")
    case .failure(let error):
        print("activateDeviceToken error: \(error)")
    }
}