Hi again,
On Saturday, I updated the library so productIdentifier should never be set to nil (so this error shouldn’t occur anymore - in theory).
Can you just confirm you’re using the latest version of the code (version 14)?
Simon
Hi again,
On Saturday, I updated the library so productIdentifier should never be set to nil (so this error shouldn’t occur anymore - in theory).
Can you just confirm you’re using the latest version of the code (version 14)?
Simon
I was using an older local copy, but referred to the line numbers as seen on github. So I’ll grab the latest code and resubmit, and let you know how it goes.
Thanks for your continued efforts on this library!
Using the latest code, under same scenario as before (restoring purchase while offline or not properly logged in, i.e get prompted for password), I get the following error:
iap_badger.lua:1012: bad argument #1 to ‘pairs’ (table expected, got userdata)
I think I know what’s happening with this one and there could be a quick fix.
With verbose output turned on, the output for the store transaction event looks like this:
IAP Badger: storeTransactionCallback event contains raw data: [\>-- raw data here \<--] Store transaction event ...
Please could you share the contents of the raw data?
Simon
0 <missing path> default 19:46:08.000000 +0100 Balloon Pop! event contains raw data:
0 <missing path> default 18:46:08.000000 +0100 Balloon Pop! table: 0x15566b70 {
0 <missing path> default 18:46:08.000000 +0100 Balloon Pop! [name] => “storeTransaction”
0 <missing path> default 19:46:08.000000 +0100 Balloon Pop! [transaction] => userdata: 0x1551f194
0 <missing path> default 18:46:08.000000 +0100 Balloon Pop! }
0 <missing path> default 18:46:08.000000 +0100 Balloon Pop! Store transaction event
0 <missing path> default 19:46:08.000000 +0100 Balloon Pop! ERROR: Runtime error
/Users/per/Dropbox/Code/workspace-Corona/DevProjects/popballoons_iap/iap_badger.lua:1012: bad argument #1 to ‘pairs’ (table expected, got userdata)
stack traceback:
[C]: in function ‘pairs’
/Users/per/Dropbox/Code/workspace-Corona/DevProjects/popballoons_iap/iap_badger.lua:1012: in function </Users/per/Dropbox/Code/workspace-Corona/DevProjects/popballoons_iap/iap_badger.lua:970>
I’ve uploaded some changes - try it now.
Simon
Works now, returns immediately if not online. I’ll be updating my UI to prevent users from getting that far if they are offline, but it is great to know that it won’t crash if they do
Thanks for quick turnaround!
No worries - glad it’s working for you.
Simon
Hello! For some reason the debug mode of IAP badger is not working on real android devices, while working well on iOS… Even the examples 1,2 and 3 (from the github page) are not showing correctly (actually at all) the debug alert (the one that lets you simulate purchase, fail and so on), tested on several android devices, without making any changes to the code.
Actually the first example from github refuses to start at all on real android device, instead showing a Runtime error, saying tap_badger.lua:1470: attempt to call field ‘purchase’ (a nil value)
Please could you post the contents of your build.settings file, your product catalogue (with your app store/google play product IDs scrubbed out) and your code for initialising IAP Badger?
Simon
PS. If debug mode is working on iOS, it’s most likely to be something with how you’re setting up your android build.
Thanks, Simon! That’s the thing, I’ve just tried the examples from the iap_badger-master folder, none of them are working correctly, when build for android… The strange thing is that the second one lets you show the “restore purchases” native alert, but not the “Remove ads” for some reason. The same thing happens to the app I am developing - the dialog just doesn’t show on real android in any of the cases…
These are my android build settings:
https://www.dropbox.com/s/febqixdgwtf4wtd/Screen%20Shot%202018-03-26%20at%2020.32.02.png?dl=0
P.S. I am using the latest corona daily build, 2018.3246, but the situation was the same with the official build as well… Maybe should try to build under Windows, to see what happens?
my build settings are like so:
settings = { plugins = { ["plugin.utf8"] = { publisherId = "com.coronalabs" }, -- includes IAP Badger as a plug in ["plugin.iap\_badger"] = { -- required publisherId = "uk.co.happymongoose", }, ["CoronaProvider.native.popup.activity"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, }, }, --Google in app billing v3 ["plugin.google.iap.v3"] = { -- required publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, }, orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", } }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { xcassets = "Images.xcassets", plist = { NSCalendarsUsageDescription = "Not used in this app", NSPhotoLibraryUsageDescription = "Not used in this app", NSCameraUsageDescription = "Not used in this app", UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --UIBackgroundModes = { "audio" }, UILaunchStoryboardName = "LaunchScreen", -- Required! NSAppTransportSecurity = { NSExceptionDomains = { ["jkabulgaria.com"] = { NSIncludesSubdomains = true, NSThirdPartyExceptionAllowsInsecureHTTPLoads = true, }, }, }, --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXX", -- replace XXXXXXXXX with your Facebook appId } } } --]] } }, -- -- Android Section -- android = { usesPermissions = { "android.permission.INTERNET", "com.android.vending.BILLING", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.CAMERA", }, }, }
Catalog and initialization:
iap = require("plugin.iap\_badger") --Called when a purchase fails local function failedListener() local function onComplete( event ) if ( event.action == "clicked" ) then local i = event.index if ( i == 1 ) then end end end -- Show alert with two buttons local alert = native.showAlert( "Внимание!", "Грешка, Моля, опитайте отново по-късно.", { "OK"}, onComplete ) end local catalogue = { --Information about the product on the app stores products = { --buy50coins is the product identifier. --Always use this identifier to talk to IAP Badger about the purchase. buyYearlyTax = { --A list of product names or identifiers specific to apple's App Store or Google Play. productNames = { apple=" ~~~", google="~~~"}, --The product type productType = "consumable", --This function is called when a purchase is complete. onPurchase=function() iap.addToInventory("yearlyTax", 1) end, --The function is called when a refund is made onRefund=function() iap.removeFromInventory("yearlyTax", 1) end, }, }, --Information about how to handle the inventory item inventoryItems = { yearlyTax = { productType="consumable" } } } local iapOptions = { --The catalogue generated above catalogue=catalogue, --The filename in which to save the inventory filename="inventory.txt", --Salt for the hashing algorithm salt = "something tr1cky to gue55!", --Listeners for failed and cancelled transactions will just remove the spinner from the screen failedListener=failedListener, cancelledListener=failedListener, --Once the product has been purchased, it will remain in the inventory. Uncomment the following line --to test the purchase functions again in future. --doNotLoadInventory=true, debugMode=true, verboseDebugOutput = true, } --Initialise IAP badger iap.init(iapOptions) --~~~~~-- some time later local function purchaseListener(product)~~~ end iap.purchase("buyYearlyTax", purchaseListener)
This works on under iOS…
P.S. On android devices, it does say “debug mode is active” … or so, but as I said, the native alert, which should appear to allow simulated purchases or fails and so on does not show, not only in my app, but in the examples as well…
P.P.S - Just build the app under Windows, and it is working normally… very strange…
What’s weird about this is:
I can see you’ve got verboseDebugOutput set to true - please could you post the (relevant) parts of the console output to see if there any clues to what is going on here?
Simon