swift - 自动续订订阅 SKProduct.PeriodUnit == 7

标签 swift in-app-purchase skproduct

我想要按钮在按钮中显示价格和订阅期,就像这样 -

enter image description here

我创建了以每周和每年为周期的自动续订订阅。我得到了值-

print("numberOfUnits : \(product.subscriptionPeriod?.numberOfUnits ?? -1)")

products size : 2
numberOfUnits : 1
numberOfUnits : 7

据我了解,yearly应该是3?我没有看到任何其他等于 7 的值。

enter image description here

最佳答案

单位数与 SKProduct.PeriodUnit 不同。首先检查 SKProduct.PeriodUnit,然后使用单位数来计算持续时间。

“订阅期持续时间的计算方法是将单位数乘以单位数。 例如,如果单位数为 3,单位为 SKProduct.PeriodUnit.month,则订阅期为 3 个月。"

引自Apple docs

关于swift - 自动续订订阅 SKProduct.PeriodUnit == 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57063764/

相关文章:

arrays - 添加多个表格 View 时访问单元格原型(prototype)

ios - 在函数参数传递的 View 上添加 subview 会导致保留循环吗?

swift - 如何创建事件指示器 View ?

ios - 从应用内购买中获取订阅者 ID

ios - 了解 TableView 中的 localizedTitle 和 localizedDescription

ios - 格式化最大非零有效数字

android - 在 android 中的 App Purchase 实现中

iOS 为应用程序内容购买本地货币

ios - 如何在沙盒模式 iOS 中测试应用内购买?

ios - SKProduct localizedTitle 总是英文