I’m working on setting up intro offers on apple and am having a problem with weekly / monthly. It seems that the enum positions for these might have swapped recently.
I set up a 1 Week free on a monthly subscription
When I call
extensionProvider.GetExtension<IAppleExtensions>().GetIntroductoryPriceDictionary();
and print out the resulting json, I see
{"introductoryPrice":"0","introductoryPriceLocale":"USD","introductoryPriceNumberOfPeriods":"1","numberOfUnits":"1","unit":"1"}
This is resulting in the free period being reported as 30 days, instead of 7.
Documentation indicates that unit 1 should map to Monthly, and not Weekly. See SubscriptionPeriodUnit in the Purchasing package:
/// <summary>
/// Used internally to parse Apple receipts. Corresponds to Apple SKProductPeriodUnit.
/// </summary>
/// <see cref="https://developer.apple.com/documentation/storekit/skproductperiodunit?language=objc"/>
public enum SubscriptionPeriodUnit
{
/// <summary>
/// An interval lasting one day.
/// </summary>
Day = 0,
/// <summary>
/// An interval lasting one month.
/// </summary>
Month = 1,
/// <summary>
/// An interval lasting one week.
/// </summary>
Week = 2,
/// <summary>
/// An interval lasting one year.
/// </summary>
Year = 3,
/// <summary>
/// Default value when no value is available.
/// </summary>
NotAvailable = 4,
};
Looking at Apple documentation, they also order the enums as Day, Month, Week, Year. However, something has switched! When I tried doing a free Month instead, the Unit was changed to “2”. This resulted in the calculated time-span being 7 days instead of 30.
So, Apple bug where they broke their API? Unity problem where things were accidentally swapped? Anyone else come across this?
Specifically, I’m using Unity Purchasing 4.11 and testing this out in the Apple Vision Pro simulator using the storekit configuration file.