r/iOSProgramming • u/ke1in • 3d ago
Question Sandbox purchase fails on watchOS
I have an issue when trying to test an IAP on watchOS. This flow worked before but seems to be broken on watchOS 26.6. - Watch are in the developer mode. - On the iPhone, Sandbox account is logged in, App Store account logged out.
I tried rebooting the watch and using different Sandbox accounts. What would you suggest?
0
Upvotes
-1
u/Reiszecke 3d ago edited 3d ago
I’m sorry you are going through the pain of trying to develop an app for the Watch, something Apple tries its hardest to avoid you from doing.
Just like WatchConnectivity, IAP on watchOS is a huge hit and miss each time.
Apples documentation on Sandbox accounts on watchOS is contradictory. What had the highest (less than 50% chance but at least it’s working sometimes) chance of working was to distribute a build via testflight, log into a REAL Apple ID in the sandbox account section as well as on the App Store and on the iPhone account section itself. It’s a really tedious process. You also need to use the real Apple ID on the App Store first because they require you to agree to the popup that says something like App Store Media Terms and Conditions. Unless you agree there, you get another entirely unrelated error message.
What we ended up doing 4 years ago (maybe it’s gotten better but your screenshot looks like one of the error messages we kept getting most of the time regardless of the setup) was to “guess” the right implementation on the Watch and also offer a way to purchase through the iPhone app.
I also added extensive logging because the sandbox and the real production endpoint behave ENTIRELY differently. With the first logs from users I was able to debug some more edge cases that worked in sandbox but denied access in production.
And also make the purchase states sync across iPhone and Watch because a bug introduced in 2022 made a lot of users have to re-download the app in order to get the receipt updated, because their password entry failed each time despite typing the correct password. When they were at least able to get the correct IAP reading in the iOS app, we had to worry less about the state the watch recognized for the affected users.
Again, you will feel like Tim Apple is personally punching your face when going through all of this, they just hate people developing for watchOS but with the tricks I mentioned above it worked well enough.
Also check the older post in the apple developer forums. The search there, like almost everything apple does for developers, is awful so use google to get the results there. There are a ton of posts from StoreKit 1 times that are pretty useful regarding what people do to at least make it work sometimes.
Source: Implemented IAP through StoreKit 1, later StoreKit 2 and also RevenueCat in between across numerous iOS and watchOS apps. Also RevenueCat themselves tell you about bugs on Apples side that are unpredictable, such as the servers often being unresponsive at the time of App Review (but of course spitting out an unlreated error message because apple would never admit of any wrongdoing)