To give you some context, I’m trying to set up non-consumable in app purchases. I’ve read the tutorial and the store.api and I have a few questions.
First, is it safe to initialize the store every time the customer opens the in-app store or is it important to only initialize it once? If I can only initialize it once, should I do it when the app launches or on enter screen in case the device has been locked and the port closed? Obviously, it would be preferable to just do it every time they open the store to be sure nothing funky has happened to the connection.
Second, when I use store.restore is that going to send me a series of transaction callbacks to process or a single transaction callback with a bunch of products in it? The documentation says that when I restore I don’t have to specify the product to restore so I’m assuming the store will send information on all purchases associated with the app. Reading between the lines in the documentation, I’m guessing it sends a series of callbacks which are handled separately, but I felt like it was prudent to ask.
You should only initialize it once. I’m not sure what the ramifications are of doing it multiple times. I usually initialize it in my main.lua as part of start up. The only gotcha is that Apple wants the store.restore() call to be made when the user pushes the “Restore” button. For Google, you can do a restore a few seconds after initializing it.
I believe the restore will result in multiple transaction call backs.
I’m trying to implement store.restore() right now on the Apple App Store. I do the call but never get anything back, not even an error.
I have a log event happening right at the beginning of the transaction listener and things work fine for purchases, but ZERO is coming back after making a call to store.restore() – anybody have any hints? This is the last thing I need to do before submitting the game!
I log that the button was pressed (via requestb.in) and then call store.restore(). I have requestb.in calls inside the transaction listener which is how I know purchases work (plus, the items show up) and how I know restore doesn’t.
Set it for something like 20-30 seconds, if the response comes back faster than that (which it almost always will) then have it cancel the timer. Normally, restores take a couple of seconds. I also like to check for an internet connection and for the store before I send the request. If they can’t actually reach the store then fail immediately. So, now you are only really covering yourself in case the person hits the restore button and they have nothing to restore.
In my case I don’t care about alerting people. If they don’t have the purchases that they payed for, I’ll get the restore event and I can do any unlocks and then show an alert thanking them. If there is nothing to restore no need to alert them. The app will stay unlocked.
Rob, if someone *thinks* they have stuff to restore and they hit the button and nothing happens, they’d likely think there was a bug in the app. At least with a message they know I looked.
I’m having trouble testing this – if I use the same sandbox test account on two devices should I be able to “buy” on one device and restore on the other?
Just to kind of bump this…in case anyone else has trouble testing the store.restore() functionality.
I was able to test it by putting the app on two devices, “buying” on one device with a sandbox test account, and then hitting the game’s Restore button on the other device (using the same test account).
I ran into a problem at first because I was trying to restore consumable items, which is a no-no. You can only restore a non-consumable item. Once I switched that, my test worked.
You should only initialize it once. I’m not sure what the ramifications are of doing it multiple times. I usually initialize it in my main.lua as part of start up. The only gotcha is that Apple wants the store.restore() call to be made when the user pushes the “Restore” button. For Google, you can do a restore a few seconds after initializing it.
I believe the restore will result in multiple transaction call backs.
I’m trying to implement store.restore() right now on the Apple App Store. I do the call but never get anything back, not even an error.
I have a log event happening right at the beginning of the transaction listener and things work fine for purchases, but ZERO is coming back after making a call to store.restore() – anybody have any hints? This is the last thing I need to do before submitting the game!
I log that the button was pressed (via requestb.in) and then call store.restore(). I have requestb.in calls inside the transaction listener which is how I know purchases work (plus, the items show up) and how I know restore doesn’t.