I would like to know how to reset a RevenueCat-enabled Mac Catalyst app's in-app purchase state so that I can test the app's in-purchases with different sandbox users and with local StoreKit testing. Below is a more in-depth description of the issue I’ve had and how I've (so far unsuccessfully) tried to resolve it.
(Note: in what follows, references to "app user IDs" are always to the anonymous app user IDs that RevenueCat automatically provides.)
Prior to the introduction of local StoreKit testing for in-app purchases, it was useful to have multiple sandbox accounts to test in-app purchases (since a developer could use any one sandbox account only once to test a particular IAP— as you probably know, there's no way to "roll back" a purchase in a single sandbox account to try testing it again with that account).
When I wanted to test an in-app purchase with a new sandbox user on the same iOS / iPadOS device on which a previous sandbox user was logged in, the following procedure reliably reset the app on the device, so that I could log in on that device with the new sandbox user:
On the iOS / iPadOS device…
I deleted the app.
In the Settings app -> App Store, I signed out of the sandbox account listed there.
I restarted the device.
I re-installed the app using Xcode.
Now I am developing a Mac Catalyst version of the app, and the analogous version of the above procedure (described below) fails to reset the app on the Mac— no matter what I do on the Mac (including trying to sign in with a new Sandbox account via Preferences in the App Store app), the app continues to register the same RevenueCat App User ID for the previously-signed-in sandbox user. The result is that on the Mac I can neither try out in-app purchases with a different sandbox user, nor make use of local StoreKit testing on the Mac (after I had previously logged in on it as a particular sandbox user).
Here's the “reset” procedure I've tried:
On the Mac…
I deleted Xcode's entire Derived Data folder (in which is contained the Mac Catalyst app). I also looked for any other preferences / traces of the app on the Mac, and deleted whatever I found.
In the App Store app -> Preferences, I signed out of the sandbox account listed there.
I restarted the Mac.
I re-installed the app on the Mac using Xcode.
As noted above, this procedure fails to reset the app on the Mac— no matter what I do on the Mac (including trying to sign in with a new Sandbox account via Preferences in the App Store app), the app continues to register the same RevenueCat App User ID for the previously-signed-in sandbox user. Again, the result is that on the Mac I can neither try out in-app purchases with a different sandbox user, nor make use of local StoreKit testing on the Mac (after I had previously logged in as a particular sandbox user).
To try resolving the issue, I could, of course, simply delete the app user ID via the RevenueCat website. I'm a little wary to do that, though, given that (1) it's irreversible and (2) I want to be absolutely sure I don't accidentally delete the ID for a user with live purchases. I don't think I'll end up doing that with the "stuck" app user ID on the Mac noted above, since it is listed as one of the sandbox app user IDs in my RevenueCat account; but my RevenueCat account also strangely lists the app user ID as one that was "first seen using the app" back in March, despite my logging in to the Mac with the associated sandbox user account for the first time just a few days ago. (That sandbox user account made no purchases prior to a couple days ago, and the stuck user ID has no aliases.) Given RevenueCat's reporting that the user ID was "first seen using the app" back in March, I worry that the user ID somehow got associated with some other (potentially "live purchase") user's use of the app.
If anyone has any suggestions for resetting the app on the Mac (for use with different sandbox users and/or local StoreKit testing), I'd be happy to hear those tips. (And, of course, if any of you think the best idea is still deletion of the app user ID on the RevenueCat website, I'd be happy to hear that, too.) Thanks!
Best answer by Chad Mohler
Thanks for the quick and quite helpful reply. Your mention of the UserDefaults cache reminded me that (as documented in this informative article) the best current way to change a Mac app's preferences / UserDefaults settings is via the defaults command. That article points to the excellent, free Prefs Editor app, which I've used in the past (with great success) to modify a Mac app's preferences / UserDefaults settings.
Just now I used Prefs Editor to search my Mac for any preferences associated with my RevenueCat-enabled app, found the relevant RevenueCat values in the plist file unearthed by that search, deleted those values, and saved the modified plist file. The next time I built and ran from Xcode the Mac Catalyst version of the app, its purchase state had been successfully reset!
So if other RevenueCat users face a similar problem with a RevenueCat-enabled Mac Catalyst app whose purchase state is stubbornly stuck on that of a particular sandbox user, I'd recommend the above procedure (deleting the relevant RevenueCat values from the Prefs-Editor-discovered plist file for the app) to resolve the issue.
Thanks again, Sharif, for helpfully pointing me in the right direction!