I followed this video: https://www.youtube.com/watch?v=0H2SdKf4ot0 which was immensely helpful in helping me get RC setup in my SwiftUI app. I was able to get purchasing working for a single subscription using a button:
VStack {
Button(action: {
Purchases.shared.offerings { offerings, error in
if let packages = offerings?.current?.availablePackages {
Purchases.shared.purchasePackage(packages.first!, { transaction, purchaserInfo, error, userCancelled in
print("TRANSACTION: \(transaction)")
print("PURCHASER INFO: \(purchaserInfo)")
print("USER CANCELED: \(userCancelled)")
if purchaserInfo?.entitlements["Pro"]?.isActive == true {
}
})
}
}
}, label: {
Text("1 month")
.foregroundColor(.white)
.frame(maxWidth: 280)
})
}
The challenge I’m facing now is that I have 3 purchase options for my one Entitlement : monthly sub, annual sub, and lifetime. These are all ready configured in App Store Connect and on RC.
Since this example uses packages.first
(and correctly grabs the monthly sub) how do I configure my yearly and lifetime buttons? There’s no packages.second
or packages.third
Appreciate any insight. Thanks!