iOS getExternalPurchaseCustomLinkTokenIOS

Fetch an external-purchase token for the ExternalPurchaseCustomLink API (iOS 18.1+, macOS 15.1+). Pair the returned token with Apple's External Purchase Server API to report acquisition or services transactions.

Wraps ExternalPurchaseCustomLink.token(for:) — token to report transactions to Apple's External Purchase Server. iOS 18.1+, macOS 15.1+. See the Apple StoreKit reference.

Signature

swift
func getExternalPurchaseCustomLinkTokenIOS(
    _ tokenType: ExternalPurchaseCustomLinkTokenTypeIOS
) async throws -> ExternalPurchaseCustomLinkTokenResultIOS

Parameters#

  • tokenType (required, ExternalPurchaseCustomLinkTokenTypeIOS) acquisition (new customers) or services (existing customers).

Returns#

Promise<ExternalPurchaseCustomLinkTokenResultIOS> — an optional opaque token plus an optional error. Send a returned token to Apple's External Purchase Server API.

Example

swift
let token = try await OpenIapModule.shared.getExternalPurchaseCustomLinkTokenIOS(
    .acquisition
)

tokenType is ExternalPurchaseCustomLinkTokenTypeIOS.Acquisition for new customers or ExternalPurchaseCustomLinkTokenTypeIOS.Services for existing ones. The result contains the opaque token or an error.