Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

macOS StoreKit2: using AppTransaction.shared triggers user login

I plan to use the new AppTransaction.shared API in StoreKit2 to find the user's original purchase date and version for my macOS app. However, when testing this by running my app with the Xcode debugger, the app shows up with an App Store login prompt, asking for my login and password, which is undesirable for the user. The WWDC22 presentation "What's New with In-App Purchase" mentions that "StoreKit takes care of automatically updating the App Transaction when necessary", so I assumed this wouldn't be necessary.

I wanted to know if this is just a sandbox quirk, or is the "AppTransaction.shared" API supposed to trigger this prompt for all users, even in production? In that case, is it like the old "Refresh receipt" API where we shouldn't trigger this automatically when a user opens the app, and instead have a button somewhere that triggers the call? Thanks.

like image 322
Z S Avatar asked Oct 16 '25 01:10

Z S


1 Answers

It shouldn't ask in production, at least not if the user is already signed in to the App Store.

I have just released a new app version that switches from a paid model to freemium, and auto-upgrades existing users by checking AppTransaction.shared.originalAppVersion. I tested it in production by installing the old version from the App Store and updating it after releasing the new version. I was not asked to sign in when opening the new version, and the app was still able to access AppTransaction.shared, correctly detecting originalAppVersion as being the previous version.

Side note in case you're implementing a similar business model switch: Apple's reviewers use the sandbox, where originalAppVersion always returns "1.0". So if your code auto-upgrades existing users by hiding the in-app purchase option, the reviewers will never get to see it and will reject your app. So I ended up checking if AppTransaction.shared.environment is .sandbox, and not doing the auto-upgrade in that case. You can still test your auto-upgrade logic for yourself by adding an #if that skips this sandbox check in the Debug configuration.

like image 153
Amar Sagoo Avatar answered Oct 19 '25 15:10

Amar Sagoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!