
Why migrate from SwiftyStoreKit?
Qonversion makes it easy to get the list of available in-app products, make and restore purchases, check user entitlements, and validate user receipts. Server-side receipt validation guarantees the entitlements’ accuracy. Unlike with SwiftyStoreKit, you don’t need to worry about storing the information on user subscriptions. Qonversion handles entitlement logic and provides simple methods to get accurate user entitlements with just a few lines of code. Qonversion provides a cross-platform subscription infrastructure for iOS, Android, and web apps, so it’s really easy to handle end-user access across mobile and desktop apps. You can learn more about Qonversion products & entitlements here.SwiftyStoreKit Migration Steps
1. App start
SwiftyStoreKit
Qonversion
Migration Step:
Remove the SwiftyStoreKitcompleteTransactions() method, and replace it with the Qonversion SDK launch() method.
2. Load products
SwiftyStoreKit
Qonversion
Migration Step:
Products are configured in the Qonversion dashboard for Qonversion SDK and mapped to SKProducts. Configure the products in Qonversion, then replaceretrieveProductsInfo() in SwiftyStoreKit with products() in Qonversion SDK.
2. Making a purchase
SwiftyStoreKit
Qonversion
Migration Step:
Purchases are initiated from a product ID or a SKProduct in SwiftyStoreKit. In Qonversion purchases should be initiated from Qonversion Product id. Replace the SwiftyStoreKitpurchaseProduct() method with purchase(). Pass the Qonversion product id that was loaded previously.
You don’t need to parse through SKError to check if the user has cancelled the payment. The property cancelled is provided in the callback for that case.
Confirm that the subscription has been purchased by checking if the permissions object contains active entitlement for the premium content you configured in the Qonversion dashboard.
3. Restore previous purchases
SwiftyStoreKit
Qonversion
Migration step:
Just replace the SwiftyStoreKitrestorePurchases with Qonversion restore method.
3. Handling purchases started on the App Store (iOS 11 or later)
Unlike SwiftyStoreKit, Qonversion SDK supports App Store promoted in-app purchases including delayed promoted purchases or making a purchase after specific checks. For example, if you don’t want to show the purchase screen to the user before your app’s onboarding, you can delay the purchase and call it when needed. Let’s have a look at the example below:SwiftyStoreKit
Qonversion
By default App Store promoted purchases will be enabled, and purchasing flow will run on the app start. If you need additional logic set QNPromoPurchasesDelegate:Migration step:
App Store promotional offers support is available by default. If you need additional logic, then usesetPromoPurchasesDelegate() and the function shouldPurchasePromoProduct()
4. Receipt verification and user entitlements
SwiftyStoreKit
Receipt verification is done locally in SwiftyStoreKit. This might lead to inaccurate subscription status data and is not recommended by Apple.Qonversion
Qonversion provides server-side receipt validation out-of-the-box. You can check the user subscription status as follows:Active Subscriptions Migration
There are several ways to transmit the data on subscribers that have already purchased a subscription using SwiftyStoreKit to Qonversion.1. First option
Provide your users with a restore purchase option. For example, you can direct them to the screen where restore purchase is available. Qonversion will get all the required data including the historical data for analytics once the subscription is restored.2. Second option
Trigger restore purchase automatically for users, who subscribed using SwiftyStoreKit. This will get all the required data. Please note, triggering restore will prompt a user to sign in to their Apple ID if they are not signed in already. So you need to trigger restore only once. Here is the code sample showing how to check and save in UserDefaults that a purchase has been restored for a user:3. Third option
If you have user receipts stored on your backend, you can contact us and we will import them into Qonversion.What’s Next You can check the sample iOS app with Qonversion implementation or watch the video tutorial: