Skip to main content
Solved

Unlock premium content after successful transaction - SwiftUI

  • March 10, 2022
  • 1 reply
  • 130 views

Forum|alt.badge.img+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:)

Best answer by cody

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

View original
Did this post help you find an answer to your question?
This post has been closed for comments

1 reply

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 501 replies
  • Answer
  • March 11, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings