Hi,
I have a player progress JSON file that tracks the locked-unlocked items. Also players can purchase items and unlock them, then JSON file is updated according to purchased item, say item 3 is unlocked. Moreover item 3 could have been unlocked if the player was passing a level. So the unlock function is called in two cases, iAP or in game progress.
My question is, how to make sure that player's purchase will be restored and JSON file will be updated when the app is uninstalled-installed or app is downloaded in another device?
Would you recommend to use a remote DB to store user ids and make the controls from there or does Unity provide any solution at the iAP API?
I was checking this link: https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html but not sure if this is what I need, since I will need to make a query and get the purchase history/product ids and update my JSON file at the first run.
Additionally, at the Purchaser script I have from here: https://unity3d.com/learn/tutorials/topics/ads-analytics/integrating-unity-iap-your-game?playlist=17123 there is a Restore function:
public void RestorePurchases() { // If Purchasing has not yet been set up ... if (!IsInitialized()) { // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization. Debug.Log("RestorePurchases FAIL. Not initialized."); return; } // If we are running on an Apple device ... if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer) { // ... begin restoring purchases Debug.Log("RestorePurchases started ..."); // Fetch the Apple store-specific subsystem. var apple = m_StoreExtensionProvider.GetExtension();
// Begin the asynchronous process of restoring purchases. Expect a confirmation response in
// the Action below, and ProcessPurchase if there are previously purchased products to restore.
apple.RestoreTransactions((result) => {
// The first phase of restoration. If no more responses are received on ProcessPurchase then
// no purchases are available to be restored.
Debug.Log("RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore.");
});
}
// Otherwise ...
else
{
// We are not running on an Apple device. No work is necessary to restore purchases.
Debug.Log("RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform);
}
}
Is this function being called by API automatically or should I call it ?
I have a player progress JSON file that tracks the locked-unlocked items. Also players can purchase items and unlock them, then JSON file is updated according to purchased item, say item 3 is unlocked. Moreover item 3 could have been unlocked if the player was passing a level. So the unlock function is called in two cases, iAP or in game progress.
My question is, how to make sure that player's purchase will be restored and JSON file will be updated when the app is uninstalled-installed or app is downloaded in another device?
Would you recommend to use a remote DB to store user ids and make the controls from there or does Unity provide any solution at the iAP API?
I was checking this link: https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html but not sure if this is what I need, since I will need to make a query and get the purchase history/product ids and update my JSON file at the first run.
Additionally, at the Purchaser script I have from here: https://unity3d.com/learn/tutorials/topics/ads-analytics/integrating-unity-iap-your-game?playlist=17123 there is a Restore function:
public void RestorePurchases() { // If Purchasing has not yet been set up ... if (!IsInitialized()) { // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization. Debug.Log("RestorePurchases FAIL. Not initialized."); return; } // If we are running on an Apple device ... if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer) { // ... begin restoring purchases Debug.Log("RestorePurchases started ..."); // Fetch the Apple store-specific subsystem. var apple = m_StoreExtensionProvider.GetExtension
Is this function being called by API automatically or should I call it ?