to further get my point across, and because I know Apple Engineers read this, something like this would be really ideal, it obviously does not work, but it should be this simple...
I have faith in you Apple!
struct MyMainView: View {
@State var products: [Product] = []
var body = some View {
List {
ForEach(products) { product in
ThisView(product: Product)
}
}
}
.task {
//fill up my products with my current entitlements:
products = await Transaction.currentEntitlements
}
}
struct ThisView: View {
@State var product: Product
@State private var productName = ""
@State private var productStatus = ""
@State private var expOrRenewDate = ""
@State private var isAutoRenew = "Disabled"
var body: some View {
VStack {
Text("You are subscribed to: \(productName)")
Text("Current Status: \(productStatus)")
Text("Your \(expOrRenewDate)")
Text("Your auto-renew preference is: \(isAutoRenew)")
}
.task {
let billingDate = product.expirationDate
productName = product.displayName
productStatus = product.subscription?.status.state
if (product.SubscriptionInfo.RenewalInfo.autoRenewPreference) {
isAutoRenew = "Active"
expOrRenewDate = "next billing date is \(billingDate)"
} else {
isAutoRenew = "Disabled"
expOrRenewDate = "subscription will expire on \(billingDate)"
}
}
}
}