store.restore doesn't call back if there is no items to restore

I am not sure if this is a Corona Bug, or if there is a best practice around it. But, definitely not having any luck.
The basic issue is that when you call store.restore() in either iOS or Android for non-consumable products, the store never calls back. Consequently my code has no way of responding. Is there a way to get a callback? Or should I do a timeout?

This is creating a huge problem since currently, my app shows the activity circle and hangs while waiting for this response back from the store API. The idea is that if the store API responds with a successful restore, than we would go ahead and unlock certain assets before the user proceeds. But since we are not getting any callbacks currently, our code just hangs. What should we do to handle such a case?

I can’t imagine I am the only one with this issue. What are others doing?

Thx!
[import]uid: 41124 topic_id: 28055 reply_id: 328055[/import]

Would you do me a favor and file a bug with us so I can track this? (Paste the bug number here.)

On iOS, we *might* be able to give you a finished callback if iOS provides one. (Apple’s documentation is unclear about what it will do in this case.) But this will have to be added in a future Corona build. I don’t know when it will be scheduled. And I don’t know what we will be able to do about Android.

However, in general, you may need to worry about the network connection breaking while in the middle of a restore. In this case, I’m not sure what will happen. (I hope Apple will trigger one of the store error callbacks, but again, their documentation is unclear on this.) Also, you may need to be prepared for a really slow network connection where a restore might take longer than you would like. So either designing your interface so it understands the asynchronous nature of the network or using a timeout might be a good idea regardless.
[import]uid: 7563 topic_id: 28055 reply_id: 113555[/import]

@ewing, thanks. I have just filed Bug #15350.

To your other point, during my testing, I do remember that on Android, if there is no network, the store.restore() will trigger a callback event with errorType. I don’t remember if iOS does the same.

Thanks! [import]uid: 41124 topic_id: 28055 reply_id: 113583[/import]

Yea its strange, I have seen a few different posters who see this same issue, but I would think if EVERYONE had this issue then there would be more of a fuss about it? I wonder if others know something we dont? [import]uid: 19620 topic_id: 28055 reply_id: 113918[/import]

I was going to post a message about this exact situation.

I have a game that’s been out for quite a while now, and I had always just re-issued a ‘purchase’ store command when the user wanted to unlock a level. This worked pretty well, and if you had already purchased the IAP the store alert tells you that you have already purchased it and all is good. The experience for the user though is a bit confusing as they are asked to enter their login details in a purchase dialog - this might scare people into thinking they are actually going to be paying again for something they had already purchased in the past (before an app reinstall, or on a different device).

So - I want to add an explicit ‘Restore’ button now alongside a ‘Purchase’ button, so the user experience is less confusing.

The problem is, if I issue a ‘store.restore()’ command for a user who HAS previously purchased the IAP, everything works great, and the restore calls the callback handler that was passed in the store.init(…) method -

*** BUT ***

The PROBLEM is that if a user has NEVER purchased an IAP before, but they trigger the store.restore() method (by tapping a ‘Restore’ button for example), the callback handler NEVER gets called (because there are no IAP products to ‘restore’).

So, I now have the same issue in that I have a loading message appear, but I have no way to find out whether the store network call has completed…

This is a major blocker and I can’t understand how people haven’t been hitting this already when implementing a ‘Restore’ type button in their apps.

Can a Corona rep please give an update on how to resolve this please? I am wanting to do an update to my game but have been holding off renewing my Corona subscription until I am sure I can get this working…

Thanks
Marcel. [import]uid: 9428 topic_id: 28055 reply_id: 115462[/import]

Just as feedback to the suggestion, network timeouts would be a good idea, but how would we know whether the network simply timed out, or that the network is fine but there will never be a callback from the store?

Picking an arbitrary time span to wait for a timeout may in fact kill a legitimate call to the store (for the restore function in this scenario) that might just be very slow… [import]uid: 9428 topic_id: 28055 reply_id: 115463[/import]

Bump, hoping Ansca can chime in. There must be a solution, otherwise I would think way more people would be talking about this one the forums? [import]uid: 19620 topic_id: 28055 reply_id: 115465[/import]

network timeout is what we are doing to try to mitigate the issue, but it is far from perfect. Hopefully the Corona guys will fix it soon.
[import]uid: 41124 topic_id: 28055 reply_id: 115685[/import]

I’d be interested to know what you considered when choosing the timeout interval?

I’m kinda thinking that on pressed a restore button, could check for network connectivity (ping google.com or something), and if there is network, then go with some kind of timeout that would be long enough for the Apple servers to respond.

Did you go with 30 seconds ?

And yeah I agree, there really should be a formal way to check in the SDK. [import]uid: 9428 topic_id: 28055 reply_id: 115699[/import]

@akoa
Let us know what you did for your temporary fix, would be appreciated =) [import]uid: 19620 topic_id: 28055 reply_id: 115728[/import]

I have the same problem with the store.restore() function. please fix this in one of the next daily releases. we have at the moment an new app in review and it was rejected becase the restore function was missing.

Thanks a lot
Michael
[import]uid: 96270 topic_id: 28055 reply_id: 115752[/import]

@rxmarccall We ended up just using a timer to “timeout” the request. So, if we don’t hear back from the .restore call after a certain amount of time, we assume there is nothing to be restored…

Definitely not the best solution, but that’s all we can think of… [import]uid: 41124 topic_id: 28055 reply_id: 115820[/import]

@akoa
Ok thats cool and make sense. I think I will probly just do a 10 second time out, usually wouldn’t take any longer than that right? [import]uid: 19620 topic_id: 28055 reply_id: 115822[/import]

Thats the whole problem in this scenario, you CANNOT assume a particular timeout will be sufficient. My network connection might take 30 seconds to reach Apple, where yours might do it in 10 seconds.

Having a fixed timeout will potentially give false negatives that the user didn’t have any items to restore. Its an unfortunate situation that I guess we’ll have to live with and hope that if it fails for a user due to a our self defined timeout period, that they are able to fire off another restore request that does return within the time out period if they try again. The risk (probably small in the grand scheme of things) is that a person with consistently slow connection might timeout before receiving the response from Apple, and therefore be prevented from restoring purchases.

I can imagine that if you are with one of the bad 3G carriers (at least here in Australia), it could well take a long time for that network request to complete.

It just smells funny to me …

[import]uid: 9428 topic_id: 28055 reply_id: 115837[/import]

Here are my thoughts on how to handle this: First don’t lock out access to your app with a spinner or loading message or anything while waiting to hear back from the network - the user should be able to navigate away from the screen at any time, even after pressing the restore or purchase buttons. Instead, have a dedicated area somewhere obvious on the page where you can display status messages.

Press Restore message: “Waiting for the app store”
Success message: “Product purchase successfully restored”
After n seconds of no response: “The App Store is taking longer than expected to respond. Please continue to wait or check your network connection and try again later.”

So instead of canceling the request after an arbitrary amount of time, you’re informing the user of the situation so they can decide whether they want to keep waiting or try again later. [import]uid: 48658 topic_id: 28055 reply_id: 116243[/import]

Hmmm, I have test the code on iphone ios 5.1 and the restore function works perfect! the same code on the ipad2 with ios 5.1.1 will not work… can someone test this too and give any feedback if you have the same situation… Hope the Corona Dev Team read this too…
[import]uid: 96270 topic_id: 28055 reply_id: 116274[/import]

any news on this one? [import]uid: 90610 topic_id: 28055 reply_id: 116485[/import]

@michael37
So you are saying that on ios 5.1 you do get a callback when using store.restore? [import]uid: 19620 topic_id: 28055 reply_id: 116523[/import]

some news, on another device with ios 5.0 it works after I have switch the button to ON about using mobile networks for purchases (german: Mobile Daten verwenden). if this switch in the store settings in set to ON it works too. I can’t test this on my ipad with ios 5.1.1 because this is only a Wifi Version of the ipad2, may someone test this his ipad.
[import]uid: 96270 topic_id: 28055 reply_id: 116556[/import]

Please note that this thread is specifically about the inability to get a callback after restoring for a user who has never made any IAP purchases. I think your queries are regarding IAP in general (ie, detecting if IAP is disable on the device etc). There’s lots of documentation around this, so it might be worth posting your messages into a more relevant thread so this one doesn’t get off topic. [import]uid: 9428 topic_id: 28055 reply_id: 116607[/import]