In App Purchase when network is missing

I was wondering how others deal with the in-app purchase calls when the user has their network disabled or is out of range of wifi?

For example, I initialize my store when I enter an intro page that contains the “store” button. The initialize in this case just calls store.init(“apple”,shop.transactionCallback), which appears to generate no errors. 

If the user presses the “store” button, the I call a “setupMyStore” function that checks if the store.isActive and then tries to load the products like this:

if store.isActive then if store.canLoadProducts then store.loadProducts( currentProductList, shop.loadProductsCallback ) print("after store.loadProducts, awaiting callback") end

Right here in my output logs on the device is where I hang up. The callback for loadProducts never gets called because (I am assuming) my networking is offline or wifi is out of range and the network is trying to connect to the store.

So how do you guys normally approach this? Do you do a check before allowing entry into any store.* functions if the network is available and report this as a no-no?

Curious minds gotta know…

Regards,

Paul

I forgot to mention that with wifi enabled, the app functions correctly and all store operations are working. Just the disconnected state is what I am looking for some guidance with. 

Regards,

Paul

Hi Paul,

My approach is to always check whether the network is available before doing an IAP call (and other user-initiated actions that require a network connect).  To check if there’s a network connection I use the approach I described here: http://forums.coronalabs.com/topic/33356-check-for-internet-connection/.

  • Andrew

Thanks Andrew,

I ended up going this way and it seems to be clean. Thanks for the info. 

Paul

I forgot to mention that with wifi enabled, the app functions correctly and all store operations are working. Just the disconnected state is what I am looking for some guidance with. 

Regards,

Paul

Hi Paul,

My approach is to always check whether the network is available before doing an IAP call (and other user-initiated actions that require a network connect).  To check if there’s a network connection I use the approach I described here: http://forums.coronalabs.com/topic/33356-check-for-internet-connection/.

  • Andrew

Thanks Andrew,

I ended up going this way and it seems to be clean. Thanks for the info. 

Paul