passepartout-apple/Packages/App/Tests/UILibraryTests
Davide d6c2a7f58c
Allow graceful period to work around slow receipt validation (#1139)
#1070 is very tricky. When the device boots, StoreKit operations seem to
be severely affected by on-demand VPN profiles. Slowdowns are huge and
unpredictable, as per my [report on the Apple
forums](https://developer.apple.com/forums/thread/773723). I found no
easy way to work around the chicken-and-egg situation where the VPN
requires StoreKit validation to start, but StoreKit requires network
access.

On the other hand, without StoreKit validations, the on-demand tunnel
starts on boot just fine, and so does the app. No eternal activity
indicators. StoreKit is clearly the culprit here.

Therefore, below is the strategy that this PR implements for a decent
trade-off:

- Configure a graceful period for the VPN to start without limitations.
This is initially set to 2 minutes in production, and 10 minutes in
TestFlight. Postpone StoreKit validation until then.
- After the graceful period, StoreKit validation is more likely to
complete fast
- At this point, paying users have their receipts validated and the
connection will silently keep going
- Non-paying users, instead, will see their connection hit the "Purchase
required" message

On the UI side, adjust the app accordingly:

- Drop the "Purchase required" icon from the list/grid of profiles
- The paywall informs that the connection will start, but it will
disconnect after the graceful period if the receipt is not valid
- Add a note that receipt validation may take a while if the device has
just started

This PR also introduces changes in TestFlight behavior:

- Profiles can be saved without limitations
- Profiles using free features work as usual
- Profiles using paid features work for 10 minutes
- Eligibility based on local receipt is ignored (deprecated in iOS 18)

Beta users may therefore test all paid features on iOS/macOS/tvOS for 10
minutes. Until now, paid features were only available to paying iOS
users and unavailable on macOS/tvOS. The tvOS beta was, in fact,
completely useless.

The downside is that paying iOS users will see beta builds restricted
like anybody else. I'll see if I can find a better solution later.
2025-02-05 13:00:42 +01:00
..
AppContextTests.swift Update copyright 2025-01-15 20:22:52 +01:00
OnboardingStepTests.swift Update copyright 2025-01-15 20:22:52 +01:00
ProfileEditorTests.swift Allow graceful period to work around slow receipt validation (#1139) 2025-02-05 13:00:42 +01:00