Search code examples
iosswiftapp-storestorekit

How to check the units (days, weeks, months or years) of a subscription period in SKProductDiscount?


Apple documentation:

enter image description here

Here I am able to get the number of units. How do I check if these units are days, weeks, months or years?

I couldn't find anything in the apple documentation.


Solution

  • The subscriptionPeriod property is an instance of SKProductSubscriptionPeriod.

    This class has two properties:

    • numberOfUnits
    • unit

    The unit property has an enumeration value that you can use to determine whether numberOfUnits refers to days, weeks, months or years.