Skip to content

Instantly share code, notes, and snippets.

@rkotzy
Created April 25, 2019 02:26
Show Gist options
  • Save rkotzy/d3a851f092b2352d9277da8270007ada to your computer and use it in GitHub Desktop.
Save rkotzy/d3a851f092b2352d9277da8270007ada to your computer and use it in GitHub Desktop.
func shouldShowSubscriptionOffer(_ purchaserInfo: PurchaserInfo) -> Bool {
// Check that the user has a 'pro_cat' entitlement that expired >= 7 days ago
// and check that we haven't previously shown this offer to the user
if (purchaserInfo.expirationDate(forEntitlement: "pro_cat") ?? Date()).addingTimeInterval(7*86400) <= Date() &&
!UserDefaults.standard.bool(forKey: "has_seen_promo_cat_discount")
{
return true
}
return false
}
@igor11082021
Copy link

@rkotzy

Date()).addingTimeInterval(7*86400) <= Date()

the result never changes,
so it does not make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment