Platforms to show: All Mac Windows Linux Cross-Platform
Back to StoreKit2MBS module.
StoreKit2MBS.AllTransactions(completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Queries the transactions and calls delegate to pass them.
This sequence returns the customer’s transaction history current to the moment you access it. The sequence emits a finite number of transactions. If the App Store processes additional transactions for the customer while you’re accessing this sequence, they appear in the transaction listener updates.
The transaction history includes the following in-app purchases
- Unfinished consumables
- Finished consumables that are refunded or revoked
- Non-consumables
- Auto-renewable subscriptions, including all renewals
- Auto-renewable subscriptions and non-consumables that the customer gets through Family Sharing
To get all possible transactions, including all finished consumables, set the SKIncludeConsumableInAppPurchaseHistory property list key to true.
Requires iOS 15.0, macOS 12.0 or newer.
See also:
StoreKit2MBS.AllTransactions(ProductID as String, completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
productID: Identifies the product to filter the transaction cache against.
Returns: A sequence containing all transactions for the given product.
See also:
StoreKit2MBS.beginRefundRequest(TransactionID as UInt64, completed as BeginRefundRequestCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
transactionID: The identifier of the transaction the user is requesting a refund for.
Call this function from account settings or a help menu to enable customers to request a refund for an in-app purchase within your app. When you call this function, the system displays a refund sheet with the customer’s purchase details and a list of reason codes for the customer to choose from.
When a customer requests a refund for consumable in-app purchases through your app, the App Stores sends a CONSUMPTION_REQUEST notificationType to your server. If the customer provided consent, respond by sending consumption data to the App Store using the Send Consumption Information endpoint. If not, don’t respond to the CONSUMPTION_REQUEST notification.
The App Store takes up to 48 hours to either approve or deny a refund.
StoreKit2MBS.CanMakePayments as Boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Use canMakePayments to determine at runtime whether a person can authorize payments. If the value is false, a person can’t authorize payments, so don’t offer In-App Purchases or external purchases.
Your app might need to alter its behavior or appearance when people can’t make purchases. For example, don’t enable your user interface for making In-App Purchases or external purchases when purchases are blocked.
The following conditions can cause the value of canMakePayments to be false
- A person sets the Content & Privacy Restrictions in Screen Time to prevent purchases. For more information, see Use parental controls on your child’s iPhone, iPad, and iPod touch.
- The device has a mobile device management (MDM) profile that prevents purchases. For more information, see Device Management.
- If canMakePayments is true and your app uses only StoreKit In-App Purchase APIs, the person can authorize purchases in the App Store and your app can offer In-App Purchases.
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Optional method to call when application quits.
StoreKit2MBS.currentEntitlement(ProductIdentifier as String, completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Calls delegate when the transaction data is available. Value is nil if the user isn’t currently entitled to this product. Current entitlement information applies only to non-consumables, non-renewing subscriptions, and auto-renewable subscriptions.
For iOS 15.0 to 18.4. For newer versions, you may better use currentEntitlements.
StoreKit2MBS.CurrentEntitlements(completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
The current entitlements sequence emits the latest transaction for each product the customer has an entitlement to, specifically
- A transaction for each non-consumable In-App Purchase
- The latest transaction for each auto-renewable subscription that has a Product.SubscriptionInfo.RenewalState state of subscribed or inGracePeriod
- The latest transaction for each non-renewing subscription, including finished ones
Requires iOS 15.0 or macOS 12.0 or newer.
See also:
Some examples using this method:
StoreKit2MBS.CurrentEntitlements(ProductID as String, completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
If a generic SKU is provided, the returned sequence will yield all transactions that entitle the user to Advanced Commerce Items purchased using the generic product's ID.
If an ID for a regular IAP is provided, the returned sequence will contain no more than one transaction.
productID: Identifies the product to check entitlements for.
Returns: A sequence containing all transactions that entitle the user to the product.
See also:
StoreKit2MBS.FinishTransaction(completed as FinishCompletedMBS = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Call finish() to complete a transaction after you deliver the purchased content or enable the purchased service. For on-demand resources, don’t finish the transaction until the app completes downloading the resource or you’ve otherwise delivered the resource.
Requires macOS 12.0, iOS 15.0 or newer.
StoreKit2MBS.latestTransaction(ProductIdentifier as String, completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Queries the latest transaction and calls the delegate.
This value is nil if the customer has never purchased this product.
By default, when the SKIncludeConsumableInAppPurchaseHistory property list key is false, this value excludes finished consumable in-app purchases unless they are refunded or revoked.
If you set the SKIncludeConsumableInAppPurchaseHistory property list key to true, this value returns all transactions, including consumable in-app purchases that your app marked as finished (finish()).
Requires macOS 12.0, iOS 15.0 or newer.
StoreKit2MBS.presentOfferCodeRedeemSheet
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
This method displays a system sheet in the view, where customers can enter and redeem subscription offer codes. Use this method if you generate subscription offer codes in App Store Connect.
Set up subscription offer codes in App Store Connect before calling this API. Customers can only redeem these offers in your app through the redemption sheet; don’t use a custom UI.
When customers redeem an offer code, StoreKit emits the resulting transaction in updates. Set up a transaction listener as soon as your app launches to receive new transactions while the app is running.
StoreKit2MBS.Product(Index as Integer) as Dictionary
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
We cache the products we got from QueryProducts, so you can query them anytime.
StoreKit2MBS.PurchaseProduct(ProductIdentifier as String, parentWindow as DesktopWindow, PurchaseOptions as Dictionary, completed as PurchaseProductCompletedMBS = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
The version taking a DesktopWindow as parent for dialogs.
See also:
- PurchaseProduct(ProductIdentifier as String, parentWindow as Window, PurchaseOptions as Dictionary, completed as PurchaseProductCompletedMBS = nil)
- PurchaseProduct(ProductIdentifier as String, PurchaseOptions as Dictionary, completed as PurchaseProductCompletedMBS = nil)
Some examples using this method:
StoreKit2MBS.PurchaseProduct(ProductIdentifier as String, parentWindow as Window, PurchaseOptions as Dictionary, completed as PurchaseProductCompletedMBS = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
The version taking a window as parent for dialogs.
See also:
StoreKit2MBS.PurchaseProduct(ProductIdentifier as String, PurchaseOptions as Dictionary, completed as PurchaseProductCompletedMBS = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Please query products before calling this. We find the product in the products array by the given identifier.
Call the purchase method when a customer initiates a purchase, either within your app or after selecting a promoted in-app purchase on the App Store. This method brings up the system-confirmation sheet. The user can confirm to complete the transaction or cancel it.
Include the purchase options to provide additional information about the purchase, such as
- appAccountToken to associate the purchase with the resulting transaction
- quantity, if the customer is purchasing more than one of the product
- If you’re testing your app in the sandbox environment, test an Ask to Buy scenario by setting the simulatesAskToBuyInSandbox purchase option to true.
| appAccountToken | Sets a UUID to associate the purchase with an account in your system. |
| quantity | Indicates the quantity of items the customer is purchasing. Default is 1. Maximum is 10. |
| simulatesAskToBuyInSandbox | Simulates an Ask to Buy scenario when testing your app in the sandbox environment. Set to true to simulate a child’s account asking permission to make a purchase. |
See also:
- PurchaseProduct(ProductIdentifier as String, parentWindow as DesktopWindow, PurchaseOptions as Dictionary, completed as PurchaseProductCompletedMBS = nil)
- PurchaseProduct(ProductIdentifier as String, parentWindow as Window, PurchaseOptions as Dictionary, completed as PurchaseProductCompletedMBS = nil)
StoreKit2MBS.QueryProducts(identifiers() as String, completed as QueryProductsCompletedMBS = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
identifiers: A collection of unique in-app purchase product identifiers that you previously configured in App Store Connect. StoreKit ignores any duplicate identifiers in the collection.
Use this method to get an instance of Product. Your app must have its product identifiers available to provide them to this function.
You initially create product identifiers when you configure in-app purchases in App Store Connect.
Your app can store or retrieve product identifiers in several ways, such as embedding the identifiers in the app bundle, or fetching them from your server.
If any identifiers are invalid or the App Store can’t find them, the App Store excludes them from the return value.
A product comes with these values in the dictionary:
| Key | Description |
|---|---|
| id | The product identifier. |
| displayName | The localized display name of the product, if it exists. |
| description | The localized description of the product. |
| price | The decimal representation of the cost of the product, in local currency. (as double) |
| displayPrice | The localized string representation of the product price, suitable for display. |
| isFamilyShareable | A Boolean value that indicates whether the product is available for Family Sharing in App Store Connect. |
| jsonRepresentation | The JSON representation of the product information. |
| type | A dictionary with type value and if available the localized description. |
| debugDescription | The debug description. |
Requires macOS 12.0, iOS 15.0 or newer.
Some examples using this method:
StoreKit2MBS.refreshAppTransaction(completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
This method queries the App Store server to refresh the app transaction information. This method returns a VerificationResult that contains the App Store-signed app transaction information for your app.
Calling refresh() displays a system prompt that asks users to authenticate with their App Store credentials. Call this function only in response to an explicit user action, like tapping or clicking a button.
Use this method to get an AppTransaction in the following cases
- The shared property throws an error.
- The shared property returns an unverified unverified result.
StoreKit2MBS.requestAgeRange(Age1 as integer, Age2 as Integer, Age3 as Integer, completed as RequestAgeRangeCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Use `AgeRangeService` to request a person's age range and manage their access to content on your app.
Age2 or Age3 can be zero if you only need 1 or 2 age limits.
Typically you would ask for something like 13, 15 and 18 to know whether you should display content >= 13, >= 15 and >= 18 for your app.
Your app needs to have the com.apple.developer.declared-age-range entitlement with value true to call the API.
Some examples using this method:
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
When you call this method in your shipping app and the system displays a rating and review request view, the system handles the entire process for you. Although you normally call this method when it makes sense in the user experience flow of your app, App Store policy governs the actual display of a rating and review request view. When your app calls this API, StoreKit uses the following criteria
- If the person hasn’t rated or reviewed your app on this device, StoreKit displays the ratings and review request a maximum of three times within a 365-day period.
- If the person has rated or reviewed your app on this device, StoreKit displays the ratings and review request if the app version is new, and if more than 365 days have passed since the person’s previous review.
We use current window/screen as root for the dialog.
StoreKit2MBS.SetUpdates(update as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Use updates to receive new transactions while the app is running. This sequence receives transactions that occur outside of the app, such as Ask to Buy transactions, subscription offer code redemptions, and purchases that customers make in the App Store. It also emits transactions that customers complete in your app on another device.
Note that after a successful in-app purchase on the same device, StoreKit returns the transaction through purchase delegate.
Set this when the app launches. If your app has unfinished transactions, the updates listener receives them once, immediately after the app launches. Without the Task to listen for these transactions, your app may miss them.
The updates listener receives unfinished transactions just once at app launch, but you can use the unfinished listener to get your app’s unfinished transactions at any time. For information on finishing transactions, see FinishTransaction.
Some examples using this method:
StoreKit2MBS.sharedAppTransaction(completed as TransactionsCompletedMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Queries the app transaction and calls delegate.
Use this property to get a VerificationResult that contains the App Store-signed app transaction information for your app, including the first time the app launches. StoreKit automatically keeps the app transaction up-to-date.
This property throws an error if the AppTransaction isn’t available or if the user isn’t authenticated with the App Store. Getting an AppTransaction may require network connectivity.
If your app fails to get an AppTransaction by accessing the shared property, see refreshAppTransaction.
StoreKit2MBS.ShowManageSubscriptions
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | iOS only |
Use this function to display the manage subscriptions sheet within your app. Consider adding a manage subscriptions option to your app. For design guidance on supporting this functionality, see Human Interface Guidelines > In-App Purchase > Helping People Manage Their Subscriptions.
The showManageSubscriptions function presents a manage subscription sheet that’s the same as what customers can view in their account settings in the App Store app or by choosing Settings > Apple Account > Subscriptions on an iOS or iPadOS device. The sheet displays the customer’s currently active subscription for your app and the options to view, upgrade, downgrade, or cancel their subscription.
Avoid showing the user interface for this feature in Mac apps built with Mac Catalyst and on iOS apps running on Mac computers with Apple silicon because this sheet isn’t supported in macOS
- In Mac apps built with Mac Catalyst, enclose the code in a compilation conditional block that uses the targetEnvironment(): platform condition. For more information on Mac Catalyst, see Creating a Mac version of your iPad app.
- For iOS apps running on Apple silicon, if isiOSAppOnMac is true, avoid showing the user interface for this feature.
See also:
StoreKit2MBS.ShowManageSubscriptions(GroupID as String)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | iOS only |
subscriptionGroupID: The subscription group identifier that the subscription belongs to.
See also:
StoreKit2MBS.Sync(completed as SyncCompletedMBS = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
Include some mechanism in your app, such as a Restore Purchases button, to let users restore their in-app purchases. In rare cases when a user suspects the app isn’t showing all the transactions, call sync(). By calling sync(), you force the app to obtain transaction information and subscription status from the App Store.
Calling sync()displays a system prompt that asks users to authenticate with their App Store credentials. Call this function only in response to an explicit user action, like tapping or clicking a button.
In regular operations, there’s no need to call sync(). StoreKit automatically keeps up to date transaction information and subscription status available to your app. When users reinstall your app or download it on a new device, the app automatically has all transactions available to it upon initial launch. There’s no need for users to ask your app to restore transactions — your app can immediately get the current entitlements using currentEntitlements and transaction history using all. For more information about transactions, see Transaction.
Requires macOS 12.0, iOS 15.0 or newer.
StoreKit2MBS.Transaction as Dictionary
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | StoreKit | MBS Swift Plugin | 25.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | Desktop & iOS |
The items on this page are in the following plugins: MBS Swift Plugin.