Search code examples
swiftin-app-purchasestorekit

SKProductsRequest before screen shows


I have a simple question: How do I load the SKProducts before the screen loads?

I want to do this because they start to load in viewWillAppear but that isn't enough and it takes 1-3 seconds or even more depending on the internet speed for the IAPs to properly load and if the user presses any button to buy an IAP the app crashes because they haven't loaded.

So how to I make sure that they are loaded when the screen shows up?

NOTE: It's not the initial screen. It's a separate one which shows up when the user presses a button.


Solution

  • I didn't find a complete fix for this but I disabled the buttons until the app contacts the AppStore. Not perfect because users wait a few seconds and app crashes if you press the buttons right after they are enabled but it's an improvement and I'm fine with that.