Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Android SubscriptionInfo not working

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

  1. SebGM2018

    SebGM2018

    Joined:
    Aug 3, 2018
    Posts:
    24
    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

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    3,130
    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".
     
    SebGM2018 likes this.
  3. SebGM2018

    SebGM2018

    Joined:
    Aug 3, 2018
    Posts:
    24
    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

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    3,130