In app purchases are working in my unity editor but not my actual app. Apple has also approved my IAPs. I followed a tutorial but it was not a great tutorial, and there’s not many current tutorials on the topic.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;
public class IAPScript : MonoBehaviour
{
public ShopScript ShopScript;
private string coin2000 = "////";
private string coin5000 = "////";
private string coin15000 = "///";
private string FirstUnlock = '///";
private string SecondUnlock = "///";
private string ThirdUnlock = "///";
public GameObject restoreButton;
private void Awake()
{
if (Application.platform != RuntimePlatform.IPhonePlayer)
{
restoreButton.SetActive(false);
}
}
public void OnPurchaseComplete(Product product)
{
if (product.definition.id == coin2000)
{
Debug.Log("youve gained 2000 coins");
//ShopScript.coin1();
}
if (product.definition.id == coin5000)
{
Debug.Log("youve gained 5000 coins");
//ShopScript.coin2();
}
if (product.definition.id == coin15000)
{
Debug.Log("youve gained 15000 coins");
//ShopScript.coin3();
}
if (product.definition.id == FirstUnlock)
{
Debug.Log("youve unlocked first");
PlayerPrefs.SetInt("ownCheckpoint1", 1);
}
if (product.definition.id == SecondUnlock)
{
Debug.Log("youve unlocked second");
PlayerPrefs.SetInt("ownCheckpoint2", 1);
}
if (product.definition.id == ThirdUnlock)
{
Debug.Log("youve unlocked third");
PlayerPrefs.SetInt("ownCheckpoint3", 1);
}
}
public void restore(IStoreController controller, IExtensionProvider extensions)
{
//m_StoreExtensionProvider
var apple = extensions.GetExtension<IAppleExtensions>();
// Begin the asynchronous process of restoring purchases. Expect a confirmation response in
// the Action<bool> below, and ProcessPurchase if there are previously purchased products to restore.
apple.RestoreTransactions(result => {
if (result)
{
Debug.Log("Restore purchases successful.");
// Handle restored purchases
}
else
{
Debug.LogError("Restore purchases failed.");
}
});
}
public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
{
Debug.Log(product.definition.id + "failed because" + failureReason);
}
}
^Here’s the code. Let me know if you’re able to help, thanks
