Error trapping IAP

I have my IAP ‘working’ but I’m wondering how others are error trapping IAP?

I have noticed that if the device can’t connect to the store my ‘loading’ swizzler stays on screen, presumably because there is no callback. How are people dealing with this? should I time out at some point and what would be reasonable?

All suggestions and code examples greatfully accepted :slight_smile: [import]uid: 51494 topic_id: 22701 reply_id: 322701[/import]

Hey, @ garethward, I test the network connectivity first, and if there’s no connection, I don’t unpackValidProducts (but instead, message the user to turn on Wi-Fi.) I use the code below for this purpose. I hope this helps.

Naomi

[lua] – test to see if network connection is available
local isSimulator = system.getInfo(“environment”) == “simulator”
local function testNetworkConnection()
local netConn = require(‘socket’).connect(‘www.apple.com’, 80)
if netConn == nil then
return false
end
netConn:close()
return true
end

if isSimulator or not testNetworkConnection() then
local function doNotUnpack()
– use this function to message the user
end
timerStash.newTimer = timer.performWithDelay (1000, doNotUnpack);
else
timerStash.newTimer = timer.performWithDelay (1000, unpackValidProducts);
end[/lua] [import]uid: 67217 topic_id: 22701 reply_id: 90579[/import]

Hi Naomi,

Thanks, I’d not thought of that. I’ll give it a go.

On a personal note may I say that your posts on IAP have been super helpful to me. I really do appreciate your efforts.

Cheers,
Gareth [import]uid: 51494 topic_id: 22701 reply_id: 90605[/import]

Hi Gareth, glad to hear my post helped. I went through tons of trouble getting the IAP working the first time around – I’m glad the pain I went through could help ease what-can-be-way-too-frustrating for others.

BTW, it just occurred to me if we need to unrequire the socket connection. Closing the connection might just do the job, but I’m not entirely sure.

If there’s anyone else reading this post and can suggest better alternative to what we’re trying to do here, I’m all ears.

Thanks!
Naomi [import]uid: 67217 topic_id: 22701 reply_id: 90761[/import]