purchases-ios
purchases-ios copied to clipboard
fix mac os sandbox check slowness 2
Alternative approach to #3875, also meant to address https://github.com/RevenueCat/purchases-ios/issues/3871
We're currently looking at a field called Environment in the local receipt to check whether the app is running in sandbox on macOS.
However, since it's an undocumented field, we can't trust that it will always be there, so if the value is production then we check the bundle's signature, which can be slow to run.
This PR changes that behavior so that we only perform that check if the value for that variable isn't available, which would cause a receipt parsing failure since it's marked as non-optional.
Still need to write tests for this, but it should be significantly easier than for the other PR.
@tonidero @MarkVillacampa ready for another pass, hopefully it takes me less than 3 months this time to iterate on PR comments this time
Tested on device (by forcing the environment value in the receipt) and was able to verify that I got the warning before the changes and did not get it after.
Still could be optimized further by caching the value (it won't change in a single app run) but then I started fighting Sendable and figured to live to fight another day
Looking good!