Search code examples
swiftuisubscriptionstoreview

Can I load SubscriptionStoreView in background to avoid loading screen when it's launched?


I am testing SubscriptionStoreView. https://developer.apple.com/documentation/storekit/subscriptionstoreview

When I present this view with ViewController for the first time, it shows a loading white screen.

        SubscriptionStoreView(
            productIDs: ["id"]
        )
        .subscriptionStoreButtonLabel(.action)
        .storeButton(.visible, for: .restorePurchases)
        .storeButton(.hidden, for: .cancellation)

Is there any way to load it in the background?


Solution

  • Unfortunately, the SubscriptionStoreView from StoreKit isn't designed to be preloaded in the background. It initializes and loads its content only when presented, which is why you're seeing that loading screen on the first launch. This behavior is pretty much hard-coded to ensure everything is up-to-date at the moment of access.

    One workaround could be to trigger its presentation in a subtle way before it's actually needed by the user, though this might not be the most elegant solution. You could, for instance, initially present it with very minimal visibility and then bring it up fully when you actually need it. Just a thought!

    Hope this helps a bit!