Hi there,
I’ve been searching for a few days how to implement promoted in-app purchases in my app with RevenueCat.
My environment:
- RevenueCat SDK version is 3.12.2
- iOS platform
- iOS 14
- Xcode 12.5.1
Research
- I’ve found this question in Github.
- I’ve also read the SDK reference.
Question
Now, SwiftUI apps launch using a custom struct that conforms to the App protocol, so there is no AppDelegate file anymore. My App struct is something like that:
@main
struct SimoleonApp: App {
init() {
Purchases.configure(withAPIKey: "KEY")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
My question is, where do I have to place the following function to support promoted in-app purchases?
func purchases(_ purchases: Purchases, shouldPurchasePromoProduct product: SKProduct, defermentBlock makeDeferredPurchase: @escaping RCDeferredPromotionalPurchaseBlock) {
makeDeferredPurchase { (transaction, info, error, cancelled) in
if let purchaserInfo = info {
handlePurchaserInfo()
}
}
}
Thank you.