Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question iOS subscription cancelled state

Discussion in 'Unity IAP' started by shimizuzu, May 10, 2023.

  1. shimizuzu

    shimizuzu

    Joined:
    May 12, 2022
    Posts:
    3
    Hi,

    I am developing an iOS app and implementing a subscription feature. I have a question about renewing my subscription.
    According to Unity's documentation (https://docs.unity3d.com/2020.3/Documentation/Manual/UnityIAPSubscriptionProducts.html), it should be possible to check whether the subscription has been cancelled or not by checking the value of "isCancelled", but in reality, only "Result.False" is returned. The environment I am working in is Sandbox.
    thank you.
     
  2. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    217
    Hello,

    I believe the description is misleading, the isCancelled is based on the cancellationDate in the AppleInAppPurchaseReceipt which only applies when cancelled by Apple directly or when upgrading a subscription.
    I've taken note of this and the description will be updated.

    There's also the isExpired and isAutoRenewing that might do what you're looking for.

    If you need further help for this, could you give us more detail on your case and what you're trying to verify?
     
  3. shimizuzu

    shimizuzu

    Joined:
    May 12, 2022
    Posts:
    3
    thank you.

    I have verified using the following code:
    Code (CSharp):
    1.  
    2. public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    3. {
    4.     storeController = controller;
    5.     extensionProvider = extensions;
    6.    
    7.     IAppleExtensions appleExtensions = extensionProvider.GetExtension<IAppleExtensions>();
    8.     Dictionary<string, string> introductoryPriceDictionary = appleExtensions.GetIntroductoryPriceDictionary();
    9.  
    10.     foreach (Product product in controller.products.all)
    11.     {
    12.         if (item.receipt != null && item.definition.type == ProductType.Subscription) {
    13.             string introJson = introductoryPriceDictionary[product.definition.storeSpecificId];
    14.  
    15.             // receipt check
    16.             if (CheckReceiptOfApple(product.receipt))
    17.             {
    18.                 SubscriptionManager p = new SubscriptionManager(product, introJson);
    19.                 SubscriptionInfo info = p.getSubscriptionInfo();
    20.  
    21.                 CheckSubscriptionInfo(info);
    22.                
    23.                 Debug.Log("isExpired " + info.isExpired());
    24.                 Debug.Log("isAutoRenewing " + info.isAutoRenewing());
    25.             }
    26.         }
    27.     }
    28. }
    29.  
    As a result, even after the user cancels, isExpired remains False, and isAutoRenewing remains True. This is the same result as before the cancellation.

    What I'm trying to achieve is to determine whether the subscription will be renewed in the next billing cycle or if it will be canceled.
    For example, I'm looking for the following behavior:
    1.Purchase subscription product A.
    2.isAutoRenewing is True.
    3.Cancel subscription product A.
    4.isAutoRenewing becomes False.
    However, in reality, isAutoRenewing always remains True.
     
  4. Simon75012

    Simon75012

    Joined:
    Sep 15, 2016
    Posts:
    79
    Hi, we're facing the exact same issue. We want to display a special Paywall with discount if we know the user won't renew at the end of the active period. The users will still have access to the premium features, but we want to try to make them resubscribe to an other plan.

    I confirm that isAutoRenewing, isCancelled, isSubscribed, isExpired doesn't update after user cancel the renew.
    We've tested it in production, and none of those variable changes.

    If you figure it out, please let me know. We'll dig on our side as well.
     
  5. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,162
    Hi there / all,

    updating these values would require fetching them from the App Store periodically. Unity IAP does not do this, therefore it is mostly unaware of any live changes on subscriptions. To receive live updates, you would need to have a server connect to App Store Server Notifications, which processes these notifications in the moment they happen, so users can retrieve their updated inventory (from your server).

    #AD
    I am offering a Receipt Validation Service that makes your IAPs most secure and additionally, implements App Store Server Notifications for real-time purchase and subscription updates. The service manages user's inventory, so it can be requested at any time, for displaying resubscribe offers or just telling them when exactly their subscription expires. It can be implemented using a separate Unity SDK or in combination with my "Simple IAP System" asset on the Asset Store.
     
  6. Simon75012

    Simon75012

    Joined:
    Sep 15, 2016
    Posts:
    79
    Thanks, we will try your service shortly!
     
    Baroni likes this.