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

Thanks Rob, hope it will be something that can be fixed.  There has been lots of developers wanting a real solution to this.

I will try to summarize what the engineer said.  The Apple iOS sdk could do the call back, however it’s not possible with Android.  For API consistency, at this time, they behave the same.  They are aware of the problem but suggest that the timer method is the best option.

I just want to make sure something is clear.   Our store.restore() call does not call the transaction listener on iOS.  We want function to behave the same on both platforms where possible.

Thanks for this thread.  Has been quite useful, at least to learn that this does not work the way we want it to.    :slight_smile:

Does someone have some sample code for the network timeout workaround?  I’ve seen the timeout thing when doing a network.request, but not sure what the proper way to do a workaround when doing the store.restore() function call.

Appreciate any guidance.

+1 would appreciate a nice clean sample, going to need to do the timer method, having lots of customers get confused while trying to restore purchases.

Anyone for an example or just a hint as to how to handle the timeout?

@rxm and thedog,

here is how I handle the timeout, I first check for a connection by pinging google, if its alive I then call store.restore() and display the activity indicator for 20 seconds after which it closes.

here some code

[lua]

function restoreItem1 (callbackFunction)
    local socket = require(“socket”)

    local test = socket.tcp()
    test:settimeout(1000)                   – Set timeout to 1 second

    local testResult = test:connect(“www.google.com”, 80) – Note that the test does not work if we put http:// in front

    if not(testResult == nil) then
        store.restore()
        native.setActivityIndicator(true);
        callback = callbackFunction;
        timer.performWithDelay(20000,timerInterval,1)

        print(“Internet access is available”)
    else
        native.showAlert(“Oops!” , “Please check your internet connection and try again.” , {“Dismiss”})
        print(“Internet access is not available”)
    end

    test:close()
    test = nil

end

[/lua]

hth :slight_smile:

@bubblebobble

Thank you very much for sharing this.

Thanks, bubblebobble.

That is similar to how I implemented it.  I was wondering if someone had done something more tied into the process versus just a separate thing, and I was not understanding what the best code method for this might be.

I do appreciate you sharing.  Thank you.

Thanks for this thread.  Has been quite useful, at least to learn that this does not work the way we want it to.    :slight_smile:

Does someone have some sample code for the network timeout workaround?  I’ve seen the timeout thing when doing a network.request, but not sure what the proper way to do a workaround when doing the store.restore() function call.

Appreciate any guidance.

+1 would appreciate a nice clean sample, going to need to do the timer method, having lots of customers get confused while trying to restore purchases.

Anyone for an example or just a hint as to how to handle the timeout?

@rxm and thedog,

here is how I handle the timeout, I first check for a connection by pinging google, if its alive I then call store.restore() and display the activity indicator for 20 seconds after which it closes.

here some code

[lua]

function restoreItem1 (callbackFunction)
    local socket = require(“socket”)

    local test = socket.tcp()
    test:settimeout(1000)                   – Set timeout to 1 second

    local testResult = test:connect(“www.google.com”, 80) – Note that the test does not work if we put http:// in front

    if not(testResult == nil) then
        store.restore()
        native.setActivityIndicator(true);
        callback = callbackFunction;
        timer.performWithDelay(20000,timerInterval,1)

        print(“Internet access is available”)
    else
        native.showAlert(“Oops!” , “Please check your internet connection and try again.” , {“Dismiss”})
        print(“Internet access is not available”)
    end

    test:close()
    test = nil

end

[/lua]

hth :slight_smile:

@bubblebobble

Thank you very much for sharing this.

Thanks, bubblebobble.

That is similar to how I implemented it.  I was wondering if someone had done something more tied into the process versus just a separate thing, and I was not understanding what the best code method for this might be.

I do appreciate you sharing.  Thank you.

Bump bump bump bump. Why can this not return anything to the callback? Is it technically impossible?

Like others have said, people may hit that button and nothing happens. Timeout is a option but leaning towards a new SDK entirely.

Sorry just angry I have to lose valuable time messing around with obvious things that should work.

I totally understand wanting to be consistent on the 2 platforms, after all the idea of Corona SDK is not having to write your game twice. However, something as specific as the stores (as they involved users spending money) it seems full control is needed surely.

It was my understanding that at least on iOS, the store does not return anything if there are no purchases to restore.  So unless all the different app stores consistently returned when there were no purchases, the only way to do this the same across all platforms is for the developer to code something that works best for the app.

Each store’s eco system is drastically different.  There are limits to what we can do to make them behave the same.   While I understand the desire to get something usable back from store.restore() when there is nothing, if you think about the transaction states, there isn’t a “Sorry, nothing to do at this time”.  Things like purchase has a defined outcome.  They bought it, cancelled it, or it failed.  But for store. restore() there is only two states:  nothing or “restored”.  

Common practice is to set a timer when you detect a press on your restore() call to terminate whatever you need to terminate when there is nothing to restore.  If you get the restore, process the information and do what you need to do.

Rob