Search Unity

Resolved Using saved variable to remove ads from IAP purchase?

Discussion in 'Visual Scripting' started by Dudusstar, Apr 26, 2021.

  1. Dudusstar

    Dudusstar

    Joined:
    Nov 19, 2020
    Posts:
    59
    Hi everyone! I have this doubt about how to remove ads from my game after a game purchase. I got everything set up and ready, when the player clicks the button and purchases the game, I set the bool saved variable "HasBoughtTheGame" to true and then the banners, rewarded ads and interstitials in the game never will show up again.

    This is the script I'm using:

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using Bolt;
    6. using UnityEngine.Purchasing;
    7. using System;
    8.  
    9. public class PurchaseGame : MonoBehaviour
    10. {
    11.     private string purchasedgame = "XXXX";
    12.     public void OnPurchaseComplete(Product product)
    13.     {
    14.         if (product.definition.id ==purchasedgame)
    15.         {
    16.             Variables.Saved.Set("HasBoughtGame", true);
    17.             Debug.Log("Game Purchased");
    18.         }
    19.  
    20.     }
    21.  
    22.  
    23.     public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
    24.  
    25.     {
    26.         Debug.Log("Purchase failed");
    27.      
    28.     }
    29. }
    30.  

    My question is, if the user uninstalls the game, do the variable get set to false and the ads will be showing again?

    Do you know any other way to do thatw ith bolt visual scripting?

    Thank you for your time and support!!!
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,065
    Once an app is deleted, all its local data is gone as well. It's not a Bolt problem. Industry standard is to use Cloud Save for this so you need to look into that, either some multi-platform solution that targets both iOS and Android or look into Google Play Services and whatever the Apple alternative is.
     
    Dudusstar likes this.
  3. Dudusstar

    Dudusstar

    Joined:
    Nov 19, 2020
    Posts:
    59
    Thank you so much for your help. I will check that!!!