token(for:)
Requests an external purchase token of the specified type.
Declaration
static func token(for tokenType: String) async throws -> ExternalPurchaseCustomLink.Token?Parameters
- tokenType:
A string that indicates the token type. Valid string values are:
ACQUISITION,SERVICES,IN_APP,LINK_OUT.
Mentioned in
Return Value
Returns an external purchase token of the type you specify, or returns nil if there isn’t an active token of the specified type. This method throws an error if your app isn’t eligible to use this API.
Discussion
Use this method to request tokens when your app uses the ExternalPurchaseCustomLink API.
The token types you request depend on the region in which your app offers external purchases:
For external purchases in the European Union (EU), request the
ACQUISITIONandSERVICEStoken types when your app launches and immediately associate the tokens with a customer account on your server. You can also call this method at any other time, such as before communicating or promoting offers. The method returns the token, of each type, until it expires.For external purchases in Japan, request the
IN_APPorLINK_OUTtoken types. Request anIN_APPtoken type for flows that use an alternative payment provider inside the app. Request aLINK_OUTtoken type for flows where customers can complete transactions on your website, outside of the app. For more information, see Payment options on the App Store in Japan.
The IN_APP and LINK_OUT token types for Japan are available starting in iOS 26.4.
Read and report tokens
Decode the token to read its contents, including its expiration date. For more information, see Receiving and decoding external purchase tokens. For a code example that shows requesting tokens, see ExternalPurchaseCustomLink.
Report tokens and all transactions associated with the tokens from your server, using the External Purchase Server API.