Hi, So I made an app for android, and I retrieve purchased information by saving it on the device and retrieving it from the device. (Which is data that will be lost if they delete the app)
Google saves this information, it wont even allow them to purchase the same item twice even if they delete the item.
My Question is; how do I retrieve this information from google?
This Link may help, But I dont understand it, nor how to use it(Anything Outside of MonoBehaviour and my brain stops functioning): Unity - Manual: Implementing a Store
This is my current Script:
public class Shop : MonoBehaviour
{
public GameObject IAPButton;
public LetsRoll MainScriptReference;
public int Unlocked = 0;
private void Awake()
{
IAPButton.SetActive(true);
//Unlocked = PlayerPrefs.GetInt("Unlocked"); //This Data is saved on the device!!!! MIND BLOWN WHAAAT?
Unlocked = PlayerPrefs.GetInt("Unlocked", 0); //Adding the 0, prevents it from returning null, if cant find the value for "Unlocked", it would return 0 otherwise
}
private void Start()
{
if (Unlocked == 1)
{
MainScriptReference.AdvancedModeUnlocked(true);
IAPButton.SetActive(false);
Debug.Log("Already Purchased");
}
Debug.Log("Start");
}
public void OnPurchaseComplete(Product product)
{
#if UNITY_EDITOR
StartCoroutine(DisableIapButton());
#else //This is Greyed out but its Active!
IAPButton.SetActive(false);
MainScriptReference.AdvancedModeUnlocked(true);
PlayerPrefs.SetInt("Unlocked", 1);
PlayerPrefs.Save();
#endif
}
public void OnPurchaseFailure(Product product, PurchaseFailureReason reason)
{
//I Have to give them a pop-up and tell them it did not go through or somthing
Debug.Log("Purchase of product " + product.definition.id + " failed due to" + reason);
}
private IEnumerator DisableIapButton()
{
yield return new WaitForEndOfFrame();
IAPButton.SetActive(false);
MainScriptReference.AdvancedModeUnlocked(true);
PlayerPrefs.SetInt("Unlocked", 1);
PlayerPrefs.Save();
}
}