Alipay+ DocsAlipay+ Docs

getServiceState

Call the getServiceState API to retrieve the current service state for the user.

Note: When new users call this API, but all field states cannot be retrieved, the SDK returns the following default values:

  • serviceState: .inactive
  • staticTokenStateInfo: nil
  • allDeviceTokenStateInfo: []

Method signature

copy
public static func getServiceState(completion: @escaping (Result<IAPAPServiceStateResult, IAPAPErrors>) -> Void)

Request parameters

Parameter

Type

Required

Description

completion

(Result<IAPAPServiceStateResult, IAPAPErrors>) -> Void

Yes

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

IAPAPServiceStateResult

Field

Type

Required

Description

serviceState

IAPAPServiceState

Yes

The service status of the current user.

staticTokenStateInfo

IAPAPStaticTokenStateInfo

Yes

The status of the static token.

allDeviceTokenStateInfo

Array<IAPAPDeviceTokenStateInfo>

Yes

An array of statuses of all device tokens of the user.

IAPAPServiceState

Value

Description

active

The current user is active.

inactive

The current user is inactive.

suspended

The current user is suspended.

deactivated

The current user is deactivated.

IAPAPStaticTokenStateInfo

Field

Type

Required

Description

tokenUniqueReference

String

Yes

The unique identifier to identify a static token.

status

IAPAPTokenState

Yes

The status of the static token.

IAPAPDeviceTokenStateInfo

Field

Type

Required

Description

tokenUniqueReference

String

Yes

The unique identifier to identify a device token.

status

IAPAPTokenState

Yes

The status of the device token.

deviceName

String

Yes

The name of the device.

IAPAPTokenState

Value

Description

active

The token is active.

inactive

The token is inactive.

suspended

The token is suspended.

deactivated

The token is deactivated.

Response parameters

N/A

Sample

copy
IAPApplePay.getServiceState { result in
    switch result {
    case .success(let stateResult):
        print("Get service state success: \(stateResult)")
        print("Service state: \(stateResult.serviceState)")
        print("Static token state: \(String(describing: stateResult.staticTokenStateInfo))")
        print("Device token states: \(stateResult.allDeviceTokenStateInfo)")
    case .failure(let error):
        print("Get service state error: \(error.localizedDescription)")
    }
}