New syncAttributesAndOfferingsIfNeeded method#3709
Conversation
4d9ddbf to
be9b2c8
Compare
be9b2c8 to
e784198
Compare
syncAttributesAndOfferingsIfNeeded method
tonidero
left a comment
There was a problem hiding this comment.
Left some comments, but nothing blocking
|
|
||
| func shouldProceed() -> Bool { | ||
| let now = Date() | ||
| timestamps = timestamps.filter { now.timeIntervalSince($0) <= period } |
There was a problem hiding this comment.
Oh I kinda liked the approach in android since it avoided this loop every time we check this... But it shouldn't take long at all, so I'm ok with this.
| return try await logOutAsync() | ||
| } | ||
|
|
||
| @objc func syncAttributesAndOfferingsIfNeeded(completion: @escaping (Offerings?, PublicError?) -> Void) { |
There was a problem hiding this comment.
Hmm I've been thinking whether it would be worth moving the logic inside this method to the PurchasesOrchestrator (mostly for organization purposes)... However, seems that the getOfferings method already was not moved there, so I'm ok with this for now.
| } | ||
|
|
||
| func shouldProceed() -> Bool { | ||
| let now = Date() |
There was a problem hiding this comment.
Since we are getting the current time here, it makes it more difficult to mock the values... Should we inject a provider-type class in the constructor of the limiter? That would avoid the sleep in the tests.
54b7431 to
f4679c4
Compare
**This is an automatic release.** ### New Features * Paywalls: add `updateWithDisplayCloseButton` to `PaywallViewController` (#3708) via Cesar de la Vega (@vegaro) * New `syncAttributesAndOfferingsIfNeeded` method (#3709) via Burdock (@lburdock) * Add targeting to `PresentedOfferingContext` (#3730) via Josh Holtz (@joshdholtz) * Add `currentOffering(forPlacement: String)` to `Offerings` (#3707) via Guido Torres (@guido732) * New `Package.presentedOfferingContext` (#3712) via Josh Holtz (@joshdholtz) ### Bugfixes * Mark methods with StaticString for appUserID as deprecated (#3739) via Mark Villacampa (@MarkVillacampa) ### Other Changes * [EXTERNAL] Spelling typo fix to comment (#3713) via @vdeaugustine (#3740) via Mark Villacampa (@MarkVillacampa) --------- Co-authored-by: Josh Holtz <me@joshholtz.com>
Motivation
Adding new method to manually sync attributes and fetch fresh offerings
Description
Purchases.shared.syncAttributesAndOfferingsIfNeeded()methodRateLimiterclass()