简体   繁体   中英

Auto renewable subscription SKProduct.PeriodUnit == 7

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM