Skip to content

hasEntitlement asks StoreKit every time instead of trusting a cached yes - #10

Merged
Ramiz69 merged 1 commit into
mainfrom
fix/stale-entitlement
Oct 8, 2026
Merged

Ramiz69 merged 1 commit into
mainfrom
fix/stale-entitlement

Conversation

@Ramiz69

@Ramiz69 Ramiz69 commented Oct 8, 2026

Copy link
Copy Markdown
Owner

hasEntitlement(for:) returned a cached true without asking StoreKit. That cache could outlive the entitlement when StoreKit revokes it without a Transaction.updates event — for example a cleared SKTestSession — so the product looked purchased for as long as the process ran. SnowWall's entitlement tests failed about one run in three because of it.

Now hasEntitlement(for:):

  • always reads Transaction.currentEntitlements;
  • updates the cached flag in both directions;
  • emits PurchasedProductEvent only when a product becomes entitled, like refreshEntitlements().

The public API is unchanged. The README asks for 3.1.1.

Testing: swift test passes (30 tests), and the library builds for macOS and visionOS on Xcode 27.

A cached true could outlive the entitlement: a revocation StoreKit never announces through
Transaction.updates, such as a cleared SKTestSession, left the product looking purchased for as
long as the process ran. hasEntitlement(for:) now always reads Transaction.currentEntitlements and
brings the cached flag into line in both directions, emitting PurchasedProductEvent only when a
product becomes entitled. README asks for 3.1.1.
@Ramiz69
Ramiz69 merged commit 4d6293c into main Oct 8, 2026
1 check passed
@Ramiz69
Ramiz69 deleted the fix/stale-entitlement branch October 8, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant