Solved

Unlock premium content after successful transaction - SwiftUI

  • 10 March 2022
  • 1 reply
  • 94 views

Badge +2

Hey everyone,

I am struggling how to unlock premium content after successful transaction. Based on docs and github a came up with :

            Purchases.shared.getCustomerInfo { (info, error) in

                guard let info = info, error == nil else { return }

                if info.entitlements.all["allaccess"]?.isActive == true{

                    //pro content here

                } else {

                    //free content

                }

            }

        }

but it throws errors at does not seems like to work.

I have RC 4.0.0

 

Thanks for helping:)

icon

Best answer by cody 11 March 2022, 18:46

View original

1 reply

Userlevel 6
Badge +8

Hey @Filip Vlcek!

I’d recommend creating a view model to store your latest CustomerInfo to reference from your SwiftUI views. You can see an example of this in our SwiftUI sample here: https://github.com/RevenueCat/purchases-ios/tree/main/Examples/MagicWeatherSwiftUI

Reply