open()
Presents a continuation sheet that enables people to choose whether your app shows its link for external purchases.
Declaration
static func open() async throwsMentioned in
Discussion
Use this method if your app configures the SKExternalPurchaseLink property list key.
Call this asynchronous method to have the system attempt to open the external purchase link, as shown below:
try await ExternalPurchaseLink.open()To use this method, follow these steps:
Call canOpen to determine whether to display a button or other user-interface controls that enable you to call open(). If it returns
true, your app can display the user-interface controls to enable deliberate user interaction.In response to deliberate user interaction, such as tapping a button, call open(). The system displays the continuation sheet that enables the user to choose whether to continue to view your app’s external purchase URL. This asynchronous method returns before the system presents the continuation sheet, and throws an error if canOpen is
false.
If the person chooses to continue, this method opens the current storefront’s destination URL that you configure in the SKExternalPurchaseLink property list key and appends an external purchase token and the app’s bundleID to the URL. For example, StoreKit opens the following URL on the default browser if your destination URL is https://site.example.com:
https://site.example.com?externalPurchaseToken=ewoJImFwcEFwcGxlSWQiOjEyMzQ1Njc4OTAsCgkiYnVuZGxlSWQiOiJjb20uZXhhbXBsZSIsCgkidG9rZW5DcmVhdGlvbkRhdGUiOjE3MDYxNjk2MDAwMDAsCgkiZXh0ZXJuYWxQdXJjaGFzZUlkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIgp9&bundleId=com.example
Handle errors
This method throws a StoreKitError if any of the following are true:
Your app doesn’t have the com.apple.developer.storekit.external-purchase-link entitlement.
You haven’t configured external purchases for the current App Store storefront in SKExternalPurchaseLink.
The current App Store storefront doesn’t support external purchases.
The person is ineligible to make external purchases.
A network or system error occurs.
For more information about App Store storefronts, see Storefront.