Handling the delay from store.init()

This is my first time working with in app purchases. While testing, I see that my once very responsive application has a major delay from the point in time store.init() is called to the time a result is returned to the application. I’m struggling with this because the long duration of a non responsive UI is unacceptable. I’m connected to reasonably fast WiFi and I can’t imagine the cellular connection time. I’d love to create another thread and put this entire process into the “background” thread but Corona doesn’t allow for more than one thread.

One way that I can solve this is to provide feedback to the user while this delay occurs, such as presenting the user with a processing image and removing it when a response is returned or a timeout value is reached. This approach doesn’t deal with the problem, it just helps the user know what’s going on.

Apple mandates that the init method is called upon application start up, to finish a possible previous transaction. However, my app is a subscription based app and really only needs to handle this scenario a few times per year.

Any suggestions or ideas?

thanks [import]uid: 38348 topic_id: 35437 reply_id: 335437[/import]

i use something like this
not perfect but it dos the job
I call init when the app starts

then on purchase

native.setActivityIndicator( true )
if(t~=nil) then
timer.cancel(t)
end
t = timer.performWithDelay( 30000,
function()
native.setActivityIndicator( false )
end)

and when i receive response from the IAP
i cancel the timer and remove the loader
[import]uid: 147488 topic_id: 35437 reply_id: 140827[/import]

I’m not sure where the delay is, I’ll ask around and see if anyone has any thoughts on that.

However, the reason you have to check each time you run the program is someone could delete the app and would loose anything you saved out indicating when their subscription was up unless you’re calling back to your server to track that information. So you init() then call restore(), make sure previous purchases are enabled and go on to the rest of your program. I understand why Apple wants it that way.

Lets look at trying to solve your delay issue. Are you doing any other activity, downloading files, loading sound files, any timers or transitions running? [import]uid: 199310 topic_id: 35437 reply_id: 140845[/import]

Thanks for your replies. Blomjens, I’m not familiar with setActivityIndicator, thanks for the tip. I’ll check it out.

Rob, I too think it is a good idea that Apple wants init called upon each startup. One thing I found interesting was that in the test sandbox, there are supposed to be a limited amount of messages that are returned in a given hour. I think the number is 8. In my experience, I have seen a huge amount of messages, 20 something be returned upon calling init. Now, that was my first time though the IAP testing and I realized that in all of the lines of messages that appear in the xCode Organizer console window, I was missing a runtime error. This was stopping execution of my finalize call. I also see a large number of messages returned when I test the 7 day subscription a lot of times. Finally, I see that all of the transaction history is returned when pressing the restore button. I’ll have to show some sort of processing indicator during this time because all of the transaction history is returned. My app is a yearly subscription, so I’m not planning on a lot of history. I just wonder what a developer with a monthly subscription app during all of this data processing… which is really slow.

To answer your question, I’m loading the returned messages (not the hex receipt) into a string and then displaying that string (for test only) in a new window. I don’t know how many messages will be returned, so I set a call back to display the “store” window after a purchase/ restore event. Yes, i’m using a timer there. Maybe I’ll cut out that part and handle the display differently.

thanks for your time.
Rob
[import]uid: 38348 topic_id: 35437 reply_id: 141005[/import]

Blomjens, what is the behavior of native.setActivityIndicator( true )? Can you post a screenshot? Does the status bar need to be displayed? I am hiding it for my app. Thanks

Rob, another question, how do you deal with restore information? In my experience, I get a lot of previous transactions (I should create my 3rd user) and there are a lot of returned messages. I read in apple IAP documentation that the very first message returned is the most recent. For an actual restore scenario, do you store the most recent transaction and forget the rest?

thanks [import]uid: 38348 topic_id: 35437 reply_id: 141011[/import]

I’ve never built a subscription app, so I’m not used to getting back anything other than the simple single purchase items. I would think for a subscription, there should be a way to see the most recent one and store that if you need it. In my case, I just store a “yes or no” flag to indicate if that product has been purchased or not.
[import]uid: 199310 topic_id: 35437 reply_id: 141125[/import]

Is there a way to remove the event handler after I get the initial restore transaction? I have a 15 second delay each time I open my app due to store.init() loading about 20+ messages. I get the entire transaction history, one slow message at a time.

thanks [import]uid: 38348 topic_id: 35437 reply_id: 141372[/import]

i use something like this
not perfect but it dos the job
I call init when the app starts

then on purchase

native.setActivityIndicator( true )
if(t~=nil) then
timer.cancel(t)
end
t = timer.performWithDelay( 30000,
function()
native.setActivityIndicator( false )
end)

and when i receive response from the IAP
i cancel the timer and remove the loader
[import]uid: 147488 topic_id: 35437 reply_id: 140827[/import]

I’m not sure where the delay is, I’ll ask around and see if anyone has any thoughts on that.

However, the reason you have to check each time you run the program is someone could delete the app and would loose anything you saved out indicating when their subscription was up unless you’re calling back to your server to track that information. So you init() then call restore(), make sure previous purchases are enabled and go on to the rest of your program. I understand why Apple wants it that way.

Lets look at trying to solve your delay issue. Are you doing any other activity, downloading files, loading sound files, any timers or transitions running? [import]uid: 199310 topic_id: 35437 reply_id: 140845[/import]

Thanks for your replies. Blomjens, I’m not familiar with setActivityIndicator, thanks for the tip. I’ll check it out.

Rob, I too think it is a good idea that Apple wants init called upon each startup. One thing I found interesting was that in the test sandbox, there are supposed to be a limited amount of messages that are returned in a given hour. I think the number is 8. In my experience, I have seen a huge amount of messages, 20 something be returned upon calling init. Now, that was my first time though the IAP testing and I realized that in all of the lines of messages that appear in the xCode Organizer console window, I was missing a runtime error. This was stopping execution of my finalize call. I also see a large number of messages returned when I test the 7 day subscription a lot of times. Finally, I see that all of the transaction history is returned when pressing the restore button. I’ll have to show some sort of processing indicator during this time because all of the transaction history is returned. My app is a yearly subscription, so I’m not planning on a lot of history. I just wonder what a developer with a monthly subscription app during all of this data processing… which is really slow.

To answer your question, I’m loading the returned messages (not the hex receipt) into a string and then displaying that string (for test only) in a new window. I don’t know how many messages will be returned, so I set a call back to display the “store” window after a purchase/ restore event. Yes, i’m using a timer there. Maybe I’ll cut out that part and handle the display differently.

thanks for your time.
Rob
[import]uid: 38348 topic_id: 35437 reply_id: 141005[/import]

Blomjens, what is the behavior of native.setActivityIndicator( true )? Can you post a screenshot? Does the status bar need to be displayed? I am hiding it for my app. Thanks

Rob, another question, how do you deal with restore information? In my experience, I get a lot of previous transactions (I should create my 3rd user) and there are a lot of returned messages. I read in apple IAP documentation that the very first message returned is the most recent. For an actual restore scenario, do you store the most recent transaction and forget the rest?

thanks [import]uid: 38348 topic_id: 35437 reply_id: 141011[/import]

I’ve never built a subscription app, so I’m not used to getting back anything other than the simple single purchase items. I would think for a subscription, there should be a way to see the most recent one and store that if you need it. In my case, I just store a “yes or no” flag to indicate if that product has been purchased or not.
[import]uid: 199310 topic_id: 35437 reply_id: 141125[/import]

Is there a way to remove the event handler after I get the initial restore transaction? I have a 15 second delay each time I open my app due to store.init() loading about 20+ messages. I get the entire transaction history, one slow message at a time.

thanks [import]uid: 38348 topic_id: 35437 reply_id: 141372[/import]