Skip to main content
Question

how to implement the code of Listening For CustomerInfo Updates

  • March 4, 2024
  • 1 reply
  • 321 views

Forum|alt.badge.img+3

Can anyone advise where to place the following code suggested by RC in the app? Currently, the sample code I’ve seen so far only places the logLevel and configure in the init() of the App struct. Not sure where to put the shared.delegate and AppDelegate extension. Thank you for sharing!

 

// Option 1: using PurchasesDelegate:
Purchases.logLevel = .debug
Purchases.configure(withAPIKey: <public_sdk_key>)
Purchases.shared.delegate = self // make sure to set this after calling configure

extension AppDelegate: PurchasesDelegate {
func purchases(_ purchases: Purchases, receivedUpdated customerInfo: Purchases.CustomerInfo) {
// handle any changes to customerInfo
}
}

This post has been closed for comments

1 reply

Forum|alt.badge.img+8
  • RevenueCat Staff
  • March 9, 2024

Hi, for app delegates we have a document that goes through how to set them up here: https://www.revenuecat.com/docs/platform-resources/apple-platform-resources/swiftui-helpers#option-2-app-delegate. We recommend putting shared.delegate after you configure and you save CustomerInfo from the delegate method to an observer viewModel.