📦 SwiftyLaunch Modules
💰 InAppPurchaseKit
Paywall

InAppPurchaseKit Paywall (InAppPurchaseView)

InAppPurchaseKit (SwiftyLaunch Module) - Paywall

Located in Sources/Views/InAppPurchaseView.swift, the InAppPurchaseView is the view that is shown when the user tries to access a feature that requires premium. You can customize this view to your liking.

Usage

The paywall is presented in the following scenarios:

  • When the user goes to settings and presses on Unlock Premium Features (opens the premium settings screen or the paywall to buy premium if the user is not subscribed)
  • When a user tries to perform an action that is wrapped in the executeIfGotPremium() function. See Lock Actions behind a Paywall.
  • When a user tries to access a view that is wrapped in the .requirePremium() view modifier. See Lock Views behind a Paywall.
  • When a sheet with the paywall is shown by calling the InAppPurchases.showPaywallSheet() function.

Customizing the Paywall

The view consists of an upper part, a carousel created in SwiftUI, which automatically scrolls through views that should sell the user the benefits of the premium plan.

The lower part of the view is created using RevenueCat's Paywall SDK and customized on the RevenueCat dashboard.

App Paywall

Upper Part (Carousel)

Here, we show a carousel of views that is stylized using common SwiftyLaunch components, such as the Hero View. You can customize the carousel as you desire directly in code.

Lower Part (Paywall Footer)

The RevenueCat Paywall Footer is less convenient to set up, but comes with a huge advantage over a hardcoded solution.

To modify it, you would have to go the RevenueCat dashboard and customize the paywall there. (As we did in the step-by-step guide)

Now, it's less convenient to have to leave Xcode to do that, but the advantage is that you can change the paywall without having to submit a new version of your app to the App Store. Neat!

Manually Showing the Paywall

As mentioned in the introduction above, we can also manually show the paywall by calling the InAppPurchases.showPaywallSheet() function.

We attach the ShowPaywallSheetWhenCalledModifier() view modifier to the root view in App.swift. This modifier then listens for the notification center notifications that would indiciate to present the paywall sheet if the user is not subscribed yet.