I wanted to have the button to show the price and the subscription period in the button like this -
I created the auto renew subscription with the period of weekly and yearly. I got the values -
print("numberOfUnits : \(product.subscriptionPeriod?.numberOfUnits ?? -1)")
products size : 2
numberOfUnits : 1
numberOfUnits : 7
From what I understand, the yearly should be 3? I don't see any other values that is equal to 7.
The number of units is different from the SKProduct.PeriodUnit
. First check for the SKProduct.PeriodUnit
and then use the number of units to calculate the duration.
"A subscription period duration is calculated by multiplying the number of units by the unit.
For example, if the number of units is 3, and the unit is SKProduct.PeriodUnit.month
, the subscription period is 3 months."
Quoted from the Apple docs