I’m trying to get subscriptions working in my game. So far, I haven’t had any issues with purchases. I am building to my phone, and using the sandbox environment to test them out.
However, the debug log from Store Manager says (currently) “Promo interface is available for 3 items” (2 non-consumable purchases and one subscription". When I do the subscription purchase in Unity, things work correctly (except I can’t seem to do any receipt validation? the results are always null)
But, when I load up the game on my device, it says “Promo interface is available for 2 items”. It lets me purchase the non-consumables, but it doesn’t do anything when I try to purchase the subscription. In Xcode, it gives me an error that the product is not available for purchase.
I’ve been searching around for different ideas for the majority of the day, and information surrounding this is just a bit hard to come by.
Okay, that’s good to know, and helps me to pin down the issue. I’m now able to purchase the subscription according to the debug in Xcode, however the functions I’ve chosen to run upon purchase throw a “NullReferenceException”—only when called from the subscription purchase. These functions are called upon opening the app as well without throwing any errors, and when I simulate the purchase through Unity, there are no errors when purchasing a subscription. What kind of reason would a function that does not depend on IAPs throw a NullReferenceException error only when being called by an IAP function (ProcessPurchase) on a subscription?
There are many reasons, I would not want to guess. Please show your code that throws the error, and the exact error message. Is this on the Sample IAP Project?
This is on my own project. Basically I have a function that resets the contents of a menu when a purchase is completed (to show the purchased items). It takes in three variables: a List, a Transform, and a string
private void GenerateMusicPanelContent()
{
Debug.Log("Start Music Panel Content");
Debug.Log(OwnedSongsList);
Debug.Log(_panelContents[0]);
FillSongPanel(OwnedSongsList, _panelContents[0].transform, "music");
Debug.Log("End Music Panel Content");
}
(Debug lines were just now added for this process)
Normally, it runs fine, because this is the same function that sets up the menus in the first place. However, when called after purchase, it throws the following error:
NullReferenceException: Object reference not set to an instance of an object.
at MenuController.GenerateMusicPanelContent () [0x00000] in <00000000000000000000000000000000>:0
at MenuController.RefreshAllMenus () [0x00000] in <00000000000000000000000000000000>:0
at Purchaser.ProcessPurchase (UnityEngine.Purchasing.PurchaseEventArgs args) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Purchasing.PurchasingManager.ProcessPurchaseIfNew (UnityEngine.Purchasing.Product product) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Purchasing.JSONStore.OnPurchaseSucceeded (System.String id, System.String receipt, System.String transactionID) [0x00000] in <00000000000000000000000000000000>:0
at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Purchasing.Extension.UnityUtil.Update () [0x00000] in <00000000000000000000000000000000>:0
As you can see, the error is in the GenerateMusicPanelContent calling FillSongPanel. Through the debugging, I was able to find that the _panelContents[0] is what is returning null. Again, this does not happen when this function is called otherwise, and doesn’t throw any errors at all. I also do not modify the _panelContents array at all, it is a serialized private array of GameObjects which is set up in the inspector.
This is not an IAP issue. One of your parameters is likely out of scope. You need to find out what is causing the null, or at least check first. This is a separate issue from the original topic. If you can reproduce with the Sample IAP project, please open a new thread