Search Unity

Android SubscriptionInfo not working

Discussion in 'Unity IAP' started by SebGM2019, Jan 2, 2019.

  1. SebGM2019

    SebGM2019

    Joined:
    Aug 3, 2018
    Posts:
    34
    Hi guys, so I need to get if the current subscription already ended, so I can put my respective code.
    So, I'm using this code to check if it has already ended, with ended I mean that is no longer subscribed, does not have any active subscriptions.
    Code (CSharp):
    1.     public static void Checker()
    2.     {
    3.         SubscriptionInfo SI = new SubscriptionInfo(ProductVIP);
    4.         SubscriptionInfo SID = new SubscriptionInfo(ProductDVIP);
    5.         SubscriptionInfo SIG = new SubscriptionInfo(ProductGVIP);
    6.         if (SI.isSubscribed() == Result.False || SID.isSubscribed() == Result.False ||  SIG.isSubscribed() == Result.False)
    7.         {
    8.             PlayerPrefs.SetInt("VIP", 0);
    9.             print("Not subscribed");
    10.         }
    11.     }
    Ok, so, I'm going to explain what is this supposed to do, in my game I have three different subscriptions, one is called "Basic VIP", another is called "Gold VIP", and the last one is the "Diamond VIP" (Yes, very creative), this could would check if any of these subscriptions has ended, or if you don't have any of these sets the variable VIP to 0.
    As you can see, I made three instances of the SubscriptionInfo class, one for each subscription available, I made this instances with the Product ID String of the subscription, because an overload of the class allows to use Product ID strings.
    The problem here is that I already tested this code with an alpha closed release from the Google Play Console, all works fine until the 5 minutes of free subscription ends, the code inside the if statement doesn't execute, so it keeps the VIP PlayerPref and it doesn't set it to zero, making like a kind of "Infinite VIP", that will never expire.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I don't quite follow the issue, but it sounds like you have a condition that you can likely catch. You need to determine why the "if statement doesn't execute".
     
    SebGM2019 likes this.
  3. SebGM2019

    SebGM2019

    Joined:
    Aug 3, 2018
    Posts:
    34
    Hey, thanks for your reply! I really apreciate it!
    Have you done this checking when subscription ends stuff before?
    It will help a lot if you can share with me an example of how you done it.
    Thanks.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446