Hello
In Sandbox, I was able to test subscription purchase. Opening the mail from Google for managing subscription, I’ve completely unsubscribed to the subscription and waited couple of minutes until the subscription disappear from the list in order to make sure I won’t have some timing issue between the moment I’ve clicked on unsubscribed and the moment I’m really unsubscribed.
My issue is that in this state, if I call RestoreTransactions from either IOS or Google extension, my subscription is still in subscribed state and I have to restart the application in order to have the actual state.
Is this a known issue? Is there a way to fix this issue?
below is the code I’m using
public void RestorePurchasedProduct()
{
#if UNITY_IOS
if (m_AppleExtensions != null)
{
m_AppleExtensions.RestoreTransactions(OnRestore);
}
#elif UNITY_ANDROID
if (m_GooglePlayStoreExtensions != null)
{
m_GooglePlayStoreExtensions.RestoreTransactions(OnRestore);
}
#endif
}
void OnRestore(bool success, string error)
{
//success is True
if (success)
{
}
else
{
}
//check if product is subscribed
bool bSubscribed = IsItemPurchased("");// <- return true until I restart teh app
}
public bool IsItemPurchased(UnityEngine.Purchasing.Product TargetProduct)
{
if (m_StoreController == null)
{
return false;
}
// If the product doesn't have a receipt, then it wasn't purchased and the user is therefore not subscribed.
if (TargetProduct.receipt == null)
{
return false;
}
if (TargetProduct.definition.type == ProductType.NonConsumable)
{
return true;
}
var subscriptionManager = new SubscriptionManager(TargetProduct, null);
var info = subscriptionManager.getSubscriptionInfo();
return info.isSubscribed() == Result.True;
}
I thank you in advance for your help
Best regards
