Hey guys,
I recently submitted my app into the App Store but it was rejected because iAP was not working. I checked to make sure that the iAP ID was correct, my tax and bank info was there, and that the App ID and provision profile had iAP enabled. This is the error message recieved in the log:
[Device] unknown [Device] Cannot connect to iTunes Store
And this is my code:
local store = require "store"; local iApLib = {}; local resultFun; local function iApListener(event) local transaction = event.transaction; if ( transaction.state == "purchased" ) then native.setActivityIndicator(false); if type(resultFun) == "table" then if resultFun[transaction.productIdentifier] then resultFun[transaction.productIdentifier](); end else if resultFun then resultFun(true); end end elseif (transaction.state == "restored") then if resultFun[transaction.productIdentifier] then resultFun[transaction.productIdentifier](); end elseif ( transaction.state == "cancelled" ) then native.setActivityIndicator(false); native.showAlert("Error", "The purchase was cancelled", {"Ok"}); elseif ( transaction.state == "failed" ) then native.setActivityIndicator(false); native.showAlert("Error", "The purchase has failed", {"Ok"}); print( transaction.errorType ) print( transaction.errorString ) end store.finishTransaction( event.transaction ) end iApLib.restoreItems = function(items) if store.canMakePurchases then resultFun = {}; for i = 1, #items do resultFun[items[i].id] = items[i].callback; end store.restore(); else native.showAlert("Error", "Purchases are not supported on this device.", {"Ok"}); end end iApLib.purchaseItem = function(item, callback) resultFun = callback; if store.canMakePurchases then native.setActivityIndicator(true); store.purchase(item); else native.showAlert("Error", "Purchases are not supported on this device.", {"Ok"}); end end if system.getInfo("platformName") == "Android" then store.init("google", iApListener); else store.init("apple", iApListener); end return iApLib;
Thanks!