Restore Purchases

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]

I don’t think there’s any way to know when there are no more restore events coming. I have the same situation - I just pop up once for each purchase restored, which can be up to 9 for my app.

Instead of a dialog box for each, you could store the ID of each transaction callback and, after a few seconds, bundle the IDs into a single dialog.
[import]uid: 36578 topic_id: 36734 reply_id: 145045[/import]

Thanks for the reply. I think it’s an awful situation for the user to be in…if you have quite a few purchases to restore, there is no way to give the user any (useful) feedback as to when they complete. So you just have to sit there and keep tapping on the notifications.

I’ll probably just display a single notification after I call store.restore(), but even that is not the best solution because it fires immediately after store.restore() (before the downloads have completed).

Ok, well…I guess that’s all I can do. Thanks! [import]uid: 141982 topic_id: 36734 reply_id: 145075[/import]

I don’t think there’s any way to know when there are no more restore events coming. I have the same situation - I just pop up once for each purchase restored, which can be up to 9 for my app.

Instead of a dialog box for each, you could store the ID of each transaction callback and, after a few seconds, bundle the IDs into a single dialog.
[import]uid: 36578 topic_id: 36734 reply_id: 145045[/import]

Thanks for the reply. I think it’s an awful situation for the user to be in…if you have quite a few purchases to restore, there is no way to give the user any (useful) feedback as to when they complete. So you just have to sit there and keep tapping on the notifications.

I’ll probably just display a single notification after I call store.restore(), but even that is not the best solution because it fires immediately after store.restore() (before the downloads have completed).

Ok, well…I guess that’s all I can do. Thanks! [import]uid: 141982 topic_id: 36734 reply_id: 145075[/import]

I don’t think there’s any way to know when there are no more restore events coming. I have the same situation - I just pop up once for each purchase restored, which can be up to 9 for my app.

Instead of a dialog box for each, you could store the ID of each transaction callback and, after a few seconds, bundle the IDs into a single dialog.
[import]uid: 36578 topic_id: 36734 reply_id: 145045[/import]

Thanks for the reply. I think it’s an awful situation for the user to be in…if you have quite a few purchases to restore, there is no way to give the user any (useful) feedback as to when they complete. So you just have to sit there and keep tapping on the notifications.

I’ll probably just display a single notification after I call store.restore(), but even that is not the best solution because it fires immediately after store.restore() (before the downloads have completed).

Ok, well…I guess that’s all I can do. Thanks! [import]uid: 141982 topic_id: 36734 reply_id: 145075[/import]

I don’t think there’s any way to know when there are no more restore events coming. I have the same situation - I just pop up once for each purchase restored, which can be up to 9 for my app.

Instead of a dialog box for each, you could store the ID of each transaction callback and, after a few seconds, bundle the IDs into a single dialog.
[import]uid: 36578 topic_id: 36734 reply_id: 145045[/import]

Thanks for the reply. I think it’s an awful situation for the user to be in…if you have quite a few purchases to restore, there is no way to give the user any (useful) feedback as to when they complete. So you just have to sit there and keep tapping on the notifications.

I’ll probably just display a single notification after I call store.restore(), but even that is not the best solution because it fires immediately after store.restore() (before the downloads have completed).

Ok, well…I guess that’s all I can do. Thanks! [import]uid: 141982 topic_id: 36734 reply_id: 145075[/import]