Solved

Monthly and Annual subscription in two buttons - Swift

  • 25 October 2021
  • 1 reply
  • 90 views

Badge +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()

    }

 

    

icon

Best answer by tina 5 November 2021, 19:54

View original

1 reply

Userlevel 5
Badge +10

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 

Reply