Why would Corona licensing.verify (to Google) be returning me an error type of “network”, and how would I fix / fault find this?
Notes:
* code for my test android app I’m using to try to get licensing work & the output is below
* I am testing via being tethered from my Android device to my iPhone for network connectivity
Q1 - Main question is above, but as an aside:
Q2 - Does the error type of “network” come from Google (indicating they did receive the verify request), or is it in fact just a response from the Corona isVerified code after a timeout (in which case the request never got to Google)???
Q3 - why do I see the event contents when I use my “dump” routine, but direct access to the event attributes (e.g. like “event.isVerified”) don’t return anything?
Q4 - I note I get a “WARNING: licensing.init() was already called for google.” after calling init on my device, even after I stopped the test corona program I may then restarted? not an issue I assume?
OUTPUT
V/Corona (20681): \> Class.forName: network.LuaLoader V/Corona (20681): \< Class.forName: network.LuaLoader V/Corona (20681): Loading via reflection: network.LuaLoader V/Corona (20681): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (20681): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (20681): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona (20681): WARNING: licensing.init() was already called for google. I/Corona (20681): . I/Corona (20681): . I/Corona (20681): I/Corona (20681): Called licensing.verify I/Corona (20681): . I/Corona (20681): RESPONSE RECEIVED!!! I/Corona (20681): DUMP OF EVENT: isError = true boolean I/Corona (20681): DUMP OF EVENT: isVerified = false boolean I/Corona (20681): DUMP OF EVENT: name = licensing string I/Corona (20681): DUMP OF EVENT: errorType = network string I/Corona (20681): DUMP OF EVENT: provider = google string I/Corona (20681): DUMP OF EVENT: expiration = 0 number I/Corona (20681): DUMP OF EVENT: expansionFiles = table: 0x30b720 table I/Corona (20681): DUMP OF EVENT: response = Error contacting server string I/Corona (20681): isVerified = I/Corona (20681): networkError = I/Corona (20681): isVerified:NIL I/Corona (20681): address:NIL I/Corona (20681): name:NIL I/Corona (20681): provider:NIL I/Corona (20681): isError:NIL I/Corona (20681): errorType:NIL I/Corona (20681): response:NIL
CODE
local widget = require( "widget" ) display.setStatusBar( display.HiddenStatusBar ) -- Status Text local text = display.newText("About to Call Google Play", 0, 0, display.contentWidth, display.contentHeight, native.systemFont, 16 ) text:setTextColor(255, 0, 0) function updateDisplay(newText) text.text = text.text .. newText print(newText) end -- debug help - to print out table contents function dump(path,t,depth) -- pairs loop for k,v in pairs(t) do print(path..k..' = ', v, " ", type(v)) if (type(v) == "table") then if depth \<= 0 then return end dump(path..k..'.',v,depth-1) end end end local function licensingListener( event ) updateDisplay("RESPONSE RECEIVED!!!") dump("DUMP OF EVENT: ", event, 3) local verified = event.isVerified local networkError = (event.errorType == "network") updateDisplay("isVerified = ", isVerified) updateDisplay("networkError = ", networkError) -- print all states out local keysArray={"isVerified", "address", "name", "provider", "isError", "errorType", "response"} local str = "" for i,keyToUse in ipairs(keysArray) do local valueStr if keysArray[keyToUse] then valueStr = tostring(keysArray[keyToUse]) else valueStr = "NIL" end str = str .. keyToUse .. ":" .. valueStr .. "\n" end updateDisplay(str) end -- Call Google local licensing = require( "licensing" ) licensing.init( "google" ) -- Status Indicator Updating timer.performWithDelay( 2000, function(event) updateDisplay(".") end, 0 ) -- Button to Initiate local myButton = widget.newButton { left = 10, top = display.contentHeight \* 0.8, width = display.contentWidth - 20, height = display.contentHeight \* 0.2, id = "button\_1", label = "Push to Initiate Verify", onRelease = function(event) licensing.verify( licensingListener ) updateDisplay("\nCalled licensing.verify") end }