-
Notifications
You must be signed in to change notification settings - Fork 0
Remove present code redemption sheet from paymentqueuewrapper #2
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
base: main
Are you sure you want to change the base?
Changes from all commits
3a5dc05
feffc97
a73b131
ad97628
49f75f1
38e1085
7ef33c6
f86c2f4
027d18d
d0f5d98
80c7c37
9c952c9
e2545dd
e7aebe3
409dcac
6ce7f09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,6 +265,7 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void | |
| fileprivate let systemInfo: SystemInfo | ||
| private let storeMessagesHelper: StoreMessagesHelperType? | ||
| private var customerInfoObservationDisposable: (() -> Void)? | ||
| private let offerCodeRedemptionSheetPresenter: OfferCodeRedemptionSheetPresenterType | ||
|
|
||
| private let syncAttributesAndOfferingsIfNeededRateLimiter = RateLimiter(maxCalls: 5, period: 60) | ||
|
|
||
|
|
@@ -307,6 +308,7 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void | |
|
|
||
| let purchasedProductsFetcher = OfflineCustomerInfoCreator.createPurchasedProductsFetcherIfAvailable() | ||
| let transactionFetcher = StoreKit2TransactionFetcher() | ||
| let offerCodeRedemptionSheetPresenter = OfferCodeRedemptionSheetPresenter() | ||
|
|
||
| let diagnosticsFileHandler: DiagnosticsFileHandlerType? = { | ||
| guard diagnosticsEnabled, #available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *) else { return nil } | ||
|
|
@@ -570,7 +572,8 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void | |
| purchasesOrchestrator: purchasesOrchestrator, | ||
| purchasedProductsFetcher: purchasedProductsFetcher, | ||
| trialOrIntroPriceEligibilityChecker: trialOrIntroPriceChecker, | ||
| storeMessagesHelper: storeMessagesHelper | ||
| storeMessagesHelper: storeMessagesHelper, | ||
| offerCodeRedemptionSheetPresenter: offerCodeRedemptionSheetPresenter | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -599,7 +602,8 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void | |
| purchasesOrchestrator: PurchasesOrchestrator, | ||
| purchasedProductsFetcher: PurchasedProductsFetcherType?, | ||
| trialOrIntroPriceEligibilityChecker: CachingTrialOrIntroPriceEligibilityChecker, | ||
| storeMessagesHelper: StoreMessagesHelperType? | ||
| storeMessagesHelper: StoreMessagesHelperType?, | ||
| offerCodeRedemptionSheetPresenter: OfferCodeRedemptionSheetPresenterType | ||
| ) { | ||
|
|
||
| if systemInfo.dangerousSettings.customEntitlementComputation { | ||
|
|
@@ -647,6 +651,7 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void | |
| self.purchasedProductsFetcher = purchasedProductsFetcher | ||
| self.trialOrIntroPriceEligibilityChecker = trialOrIntroPriceEligibilityChecker | ||
| self.storeMessagesHelper = storeMessagesHelper | ||
| self.offerCodeRedemptionSheetPresenter = offerCodeRedemptionSheetPresenter | ||
|
|
||
| super.init() | ||
|
|
||
|
|
@@ -1062,15 +1067,44 @@ public extension Purchases { | |
| } | ||
| #endif | ||
|
|
||
| #if os(iOS) || VISION_OS | ||
| #if (os(iOS) || VISION_OS) && !targetEnvironment(macCatalyst) | ||
|
|
||
| @available(iOS 14.0, *) | ||
| @available(watchOS, unavailable) | ||
| @available(tvOS, unavailable) | ||
| @available(macOS, unavailable) | ||
| @available(macCatalyst 16.0, *) | ||
| @objc func presentCodeRedemptionSheet( | ||
|
Comment on lines
+1076
to
+1077
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: macCatalyst availability should be 14.0 to match iOS version, not 16.0 |
||
| uiWindowScene: UIWindowScene? = nil | ||
| ) async throws { | ||
| try await self.presentOfferCodeRedemptionSheet(uiWindowScene: uiWindowScene) | ||
| } | ||
|
|
||
| @available(iOS 14.0, *) | ||
| @available(macCatalyst, unavailable) | ||
| @objc func presentCodeRedemptionSheet() { | ||
| self.paymentQueueWrapper.paymentQueueWrapperType.presentCodeRedemptionSheet() | ||
| @available(watchOS, unavailable) | ||
| @available(tvOS, unavailable) | ||
| @available(macOS, unavailable) | ||
| internal func presentOfferCodeRedemptionSheet(uiWindowScene: UIWindowScene?) async throws { | ||
| var windowScene = uiWindowScene | ||
| if windowScene == nil { | ||
| windowScene = try await systemInfo.currentWindowScene | ||
| } | ||
|
Comment on lines
+1088
to
+1092
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider using early return pattern here to reduce nesting and improve readability |
||
|
|
||
| guard let windowScene else { | ||
| Logger.error(Strings.storeKit.error_displaying_offer_code_redemption_sheet_no_window_scene) | ||
| return | ||
| } | ||
|
|
||
| do { | ||
| try await self.offerCodeRedemptionSheetPresenter.presentCodeRedemptionSheet( | ||
| windowScene: windowScene, | ||
| storeKitVersion: self.systemInfo.storeKitVersion | ||
| ) | ||
| } catch { | ||
| Logger.error(Strings.storeKit.error_displaying_offer_code_redemption_sheet(error)) | ||
| throw error | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
|
|
||
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.
logic: Silently swallowing errors from the async call could cause issues. Consider adding error handling or logging.