-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New syncAttributesAndOfferingsIfNeeded
method
#3709
New syncAttributesAndOfferingsIfNeeded
method
#3709
Conversation
4d9ddbf
to
be9b2c8
Compare
be9b2c8
to
e784198
Compare
syncAttributesAndOfferingsIfNeeded
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, but nothing blocking
Sources/Misc/RateLimiter.swift
Outdated
|
||
func shouldProceed() -> Bool { | ||
let now = Date() | ||
timestamps = timestamps.filter { now.timeIntervalSince($0) <= period } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -793,6 +798,23 @@ public extension Purchases { | |||
return try await logOutAsync() | |||
} | |||
|
|||
@objc func syncAttributesAndOfferingsIfNeeded(completion: @escaping (Offerings?, PublicError?) -> Void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
methodRateLimiter
class()