So I just can’t figure this out and I’m hoping some of you will have some creative input.
I’m building a storybook app that will allow you to buy and download your choice of many different stories. As a part of the app, I’m integrating a button that will allow the user to restore all of the past storybook purchases. Obviously to restore purchases, you use store.restore() which initiates that process. What happens though is that the code synchronously cycles through all of the purchases and restores them one at a time. So if I have an alert in the restore code that notifies of successful restore (as in the code below), the user will see that same alert multiple times in a row (once for each story). Instead, I’d rather just show one single notification once all of the previous purchases have been restored. If a user has purchased 20 stories, it would get quite annoying to have to click on 20 different alerts as the purchases are restored.
Here is a snippet of my code. As you can see, when the transaction.state == “restored”, you see an alert. But, that same alert fires for every story that gets downloaded.
if transaction.state == "restored" then
native.showAlert("Purchase Restored", "You have already purchased this story and it has successfully been restored to your library!", {"Ok"})
--Download Tar File Here
network.download( "http://www.mywebserverhere/tar\_files/"..transaction.productIdentifier..".tar?a=" .. os.time(), "GET", downloadTar, transaction.productIdentifier..".tar", system.DocumentsDirectory )
So, all that said…is there any way to do any kind of callback or onComplete for store.restore()? How can I be notified when all of the stories have been restored? I talked at length with another friend today and neither one of us could figure out a way to do that. Any help? Please?
I hope that makes sense. I’m happy to provide more info to clarify if need be. Thanks!
Brian
[import]uid: 141982 topic_id: 36734 reply_id: 336734[/import]