DEV Community

Yulia Kondrashova for Qonversion

Posted on • Originally published at linkedin.com

The new App Transaction API, Enhancements to StoreKit 2 and other WWDC22 updates for in-app purchases

During WWDC 2022, Apple released the latest updates for in-app purchases. In this article, we’ll briefly walk you through the most significant improvements that have already been covered: enhancements to StoreKit 2 and App Store Server API. For more details you can refer to our blog post, where you can find detailed description of these updates with advices for its implementation.

1. App transaction API is the new API to verify app purchases

The app transaction represents the signed information about the purchase of your app for the device it’s running on. It is signed using JWS and it replaces the app detail portion of the app receipt from the original StoreKit API. With App transaction you can change your business model from the paid app to a free app with in-app purchases, check who out of your customers pre-order the app, and check purchase dates.

2. New properties in the StoreKit models

  • The first one is price locale, which now is included in StoreKit products. It allows you to format numbers derived from decimal prices. For example, your customers may see how much a yearly subscription would cost them per month or how much they would save by purchasing your yearly service over your monthly service.
  • The Server Environment property allows you to tell which server environment a transaction or renewal occurred in, which could be Xcode, sandbox or production. It filters out unnecessary information to prevent it from being sent up to your server
  • Another one is Recent Subscription Start Date property. You can use this to make informed decisions about your customers based on their subscription patterns. It represent the most recent period of continuous subscription (no more than 60-days gap between any two subscribed periods). It can help you to determine a pattern of loyalty between you and your customer.
  • These properties return sentinel values — placeholder values that signal that these are not the real values you should work with — in older operating system. To overcome this limitation you need to update your test device to a new operating system. You can take advantage of these new properties on devices as far back as last year’s operating system and it’s available in Xcode 14 and above

Image description

3. SwiftUI API for redeeming subscription offer codes and asking your customers to review your app

With App Store connect, you can create uniquely named custom codes that can help you to acquire retain and win back subscribers by providing subscriptions at a discount or free for a limited time. When a customer redeems an offer code for your app, the resulting transaction is sent to the transaction listener. Be sure to set up a transaction listener as soon as your app launches to receive new and updated transactions while your app is running. This offer code view modifier is available starting on iOS 16.

Moreover, you can now ask for a review from your customer through the special sheet. You can decide the right time to request the review for your app, but you need to be aware that the prompt will only be displayed to customers a maximum of three times within a 365-day period and you shouldn’t ask customers to review the same version of your app multiple times.

4. StoreKit Messages API used to display App Store messages to your customer

StoreKit Messages represents a sheet that appears over your app to display an important information to the user. Messages are vended by the App Store and each message has a reason which is included in the Message metadata. StoreKit messages are retrieved when your app goes to foreground. For example, if you’ve increased the price of the subscription and it requires user consent, the App Store will inform affected subscribers through e-mail, push notifications, and an in-app price consent sheet. This will appear when a user opens your app, if they haven’t already responded to your price increase.

How does it work?
You app goes to the foreground. StoreKit checks whether there are some changes with the App Store. The App Store returns the message info to StoreKit, and StoreKit asks the listener for permission to display the message or defer it (if you’d like to create your own scenarios for this messages to appear). But if StoreKit doesn’t include any listener, StoreKit will display the message over your app.
Image description

Once you’ve implemented in-app purchases, don’t forget to use the analytics tools to measure how much revenue each of your products brings. Qonversion provides a complete infrastructure for in-app purchases and allows you to create and restore purchases, validate receipts, and provide your app with an accurate subscription status without a need to build your own server. If you’d like to learn more on how to set up and analyze in-app purchases and subscriptions, please read our documentation or message us here.

Discussion (0)