Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

iOS Subscription testing in TesFlight

Discussion in 'Unity IAP' started by Arlekine, Sep 11, 2019.

  1. Arlekine

    Arlekine

    Joined:
    Aug 26, 2018
    Posts:
    10
    Hi! I have some problems with implementing ios autorenewable subscription with UnityIAP. I use Subscription Manager to get information about subscription ending like in IAPDemo, but when I test my subscriptions in TestFlight - it seems like it returns value from past, because my internal date becames less than currentDateTime (DateTime.now). I expect that i would get timeExpiration as currentTime + 5 minutes (cause in testFlight 1 month subscription has duration of 5 minutes).
    Is anyone had the same problem? Am I doing something wrong, or may be it's a TestFlight bag/problem?

    Here's the method I used to check subscription:

    Code (CSharp):
    1. private void OnApplicationFocus(bool hasFocus)
    2.     {
    3.         Debug.Log("IAP Subscription check");
    4.  
    5.         m_AppleExtensions = m_StoreExtensionProvider.GetExtension<IAppleExtensions>();
    6.         Dictionary<string, string> introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary();
    7.  
    8.         foreach (var item in m_StoreController.products.all)
    9.         {
    10.  
    11.             if (item.receipt != null)
    12.             {
    13.                 if (item.definition.type == ProductType.Subscription)
    14.                 {
    15.                     string intro_json =
    16.                         (introductory_info_dict == null ||
    17.                          !introductory_info_dict.ContainsKey(item.definition.storeSpecificId))
    18.                             ? null
    19.                             : introductory_info_dict[item.definition.storeSpecificId];
    20.  
    21.                     SubscriptionManager p = new SubscriptionManager(item, intro_json);
    22.                     SubscriptionInfo info = p.getSubscriptionInfo();
    23.  
    24.                     if (info.isAutoRenewing() != Result.Unsupported && info.isSubscribed() == Result.True)
    25.                         VIPGlobalManager.instance.durationManager.SetSubscriptionEndingDate(info.getExpireDate());
    26.  
    27.  
    28.                     Debug.Log("<color=green>product id is: </color>" + info.getProductId());
    29.                     Debug.Log("purchase date is: " + info.getPurchaseDate());
    30.                     Debug.Log("subscription next billing date is: " + info.getExpireDate());
    31.                     Debug.Log("is subscribed? " + info.isSubscribed().ToString());
    32.                     Debug.Log("is expired? " + info.isExpired().ToString());
    33.                     Debug.Log("is cancelled? " + info.isCancelled());
    34.                     Debug.Log("product is in free trial peroid? " + info.isFreeTrial());
    35.                     Debug.Log("product is auto renewing? " + info.isAutoRenewing());
    36.                     Debug.Log("subscription remaining valid time until next billing date is: " +
    37.                               info.getRemainingTime());
    38.                     Debug.Log("is this product in introductory price period? " + info.isIntroductoryPricePeriod());
    39.                     Debug.Log("the product introductory localized price is: " + info.getIntroductoryPrice());
    40.                     Debug.Log("the product introductory price period is: " + info.getIntroductoryPricePeriod());
    41.                     Debug.Log("<color=green>the number of product introductory price period cycles is: </color>" +
    42.                               info.getIntroductoryPricePeriodCycles());
    43.                 }
    44.             }
    45.         }
    46.     }
    The same code i has in IAP Initialization Method.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,854
    Can you confirm which value you are seeing that "returns value from past"
     
  3. Arlekine

    Arlekine

    Joined:
    Aug 26, 2018
    Posts:
    10
    Well, its hard to answer accurately, but with clock change I calculate that it is something about 8-10 hours before current time.
    If its not enough data i will made special build to check this time and will report here.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,854
    We would need to know for sure, I'm not quite following. Which value are you referring to, please confirm which value you are seeing that "returns value from the past". You have several Debug.Log statements, which one is it?
     
  5. Arlekine

    Arlekine

    Joined:
    Aug 26, 2018
    Posts:
    10
    Oh, sorry, I didnt understand the question.
    Code (CSharp):
    1. if (info.isAutoRenewing() != Result.Unsupported && info.isSubscribed() == Result.True)
    2.                         VIPGlobalManager.instance.durationManager.SetSubscriptionEndingDate(info.getExpireDate());
    3.  
    I use this part to detect date of subscription ending - so wrong value is info.getExpireDate()
    Where 'info' is Subscription Info getted from Subscription Manager
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,854
    And what is the value of getExpireDate for a subscription that you just purchased 1 minute ago, for example? Timezone difference perhaps?
     
  7. Arlekine

    Arlekine

    Joined:
    Aug 26, 2018
    Posts:
    10
    Oh, It's really looks like its timeZone. 3 hours - difference. My time zone is UTC+3. I feel realy stupid right now. Thanks a lot!
     
unityunity