Skip to content

Commit

Permalink
Merge branch 'feature/paywalls_delegate' into 'develop'
Browse files Browse the repository at this point in the history
ADAPTY-2897 Added new adapty delegate method for paywalls
  • Loading branch information
Skifcha committed Nov 16, 2021
2 parents 6069f40 + 7a94c15 commit 77475d8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Adapty/Classes/Adapty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import UIKit

func didReceiveUpdatedPurchaserInfo(_ purchaserInfo: PurchaserInfoModel)
func didReceivePromo(_ promo: PromoModel)
@objc optional func paymentQueue(shouldAddStorePaymentFor product: ProductModel, defermentCompletion makeDeferredPurchase: @escaping DeferredPurchaseCompletion)
@objc optional func paymentQueue(shouldAddStorePaymentFor
product: ProductModel,
defermentCompletion makeDeferredPurchase: @escaping DeferredPurchaseCompletion)
@objc optional func didReceivePaywallsForConfig(paywalls: [PaywallModel])

}

Expand Down
13 changes: 9 additions & 4 deletions Adapty/Classes/IAPManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,23 @@ class IAPManager: NSObject {
let params: Parameters = ["profile_id": profileId, "paywall_padding_top": topOffset, "automatic_paywalls_screen_reporting_enabled": false]

paywallsRequest = apiManager.getPaywalls(params: params) { (paywalls, products, error) in
guard let error = error else {
func handlePaywalls(_ paywalls: [PaywallModel]?, products: [ProductModel]?) {
self.shortPaywalls = paywalls
self.shortProducts = products
self.requestProducts()
if let paywalls = paywalls {
Adapty.delegate?.didReceivePaywallsForConfig?(paywalls: paywalls)
}
}

guard let error = error else {
handlePaywalls(paywalls, products: products)
return
}

if let paywalls = self.paywalls, let products = self.products {
// request products with cached data
self.shortPaywalls = paywalls
self.shortProducts = products
self.requestProducts()
handlePaywalls(paywalls, products: products)
} else {
self.callPaywallsCompletionAndCleanCallback(.failure(error))
}
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Adapty (1.16.1)
- Adapty (1.16.3)
- Adjust (4.29.6):
- Adjust/Core (= 4.29.6)
- Adjust/Core (4.29.6)
Expand All @@ -25,7 +25,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
Adapty: 58980d056a394eb5d8ae553c298ad0a402945e5e
Adapty: a7b0104b17ca45ff9ee86bbb0eb3c0702bb93e3a
Adjust: 94f1c99429fb2a7ebe530294fd66a88d63a54922
AppsFlyerFramework: 57fb1fc68a5b8103353ce94d6e57861cbc4a55c3
Branch: 65d05ffb137ef504777cff6bd4fb6f770f17145a
Expand Down

0 comments on commit 77475d8

Please sign in to comment.