Skip to main content
Solved

Monthly and Annual subscription in two buttons - Swift

  • October 25, 2021
  • 1 reply
  • 118 views

Forum|alt.badge.img+2

I use swift code with storyboard , and I have in my code subscription button  , but this button show only Annual subscription , I have monthly and yearly product Id in my entitlement , but it’s always show yearly price after I press that button . I want make two or more buttons one for Monthly , Yearly and also Lifetime if possible . But I don’t know how .. This my code , and the : fullappaccess is the Identifier for my entitlement in revenuecat

 

Swift Code :

@objc func goPremiumButtonTapped(sender:UIButton) {



    

        

        let package = self.packagesAvailableForPurchase[sender.tag]

        

        Purchases.shared.purchasePackage(package) { (transaction, purchaserInfo, error, userCancelled) in

          

            if purchaserInfo?.entitlements.all["fullappaccess"]?.isActive == true {

                self.dismiss(animated: true, completion: nil)

            }

        }

        hapticFeedback()

    }

 

    

Best answer by tina

Hey @Hussain Barakat 

I would recommend creating these buttons programmatically so the paywall can be dynamic to your Offerings. We have sample code in Swift that’s worth checking out: https://github.com/RevenueCat/purchases-ios/blob/main/Examples/MagicWeather/MagicWeather/Sources/Controllers/PaywallViewController.swift#L24-L35 

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

1 reply

tina
RevenueCat Staff
Forum|alt.badge.img+10
  • RevenueCat Staff
  • 338 replies
  • Answer
  • November 5, 2021

Hey @Hussain Barakat 

I would recommend creating these buttons programmatically so the paywall can be dynamic to your Offerings. We have sample code in Swift that’s worth checking out: https://github.com/RevenueCat/purchases-ios/blob/main/Examples/MagicWeather/MagicWeather/Sources/Controllers/PaywallViewController.swift#L24-L35 


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