When I get the product information for my In-App-Purchases from Google, I put them in a sorted table using table.insert. This has worked fine in my testing on two different devices, however, I just got a Galaxy S6 and noticed that some of the products are not being displayed in my store. When I looked deeper into it, I found that those products are missing from the sorted table.
I’m really lost with this, could it be that the device or Android version affects how table.insert works? The device that works is Android 4.3, the Galaxy S6 is 5.0.2. Here is some code, and the output from the console:
local validProducts = event.products local invalidProducts = event.invalidProducts local sortedProducts = {} for k, product in pairs(validProducts) do product.title = string.gsub(product.title, "%s%(.+%)","") if shopInfo[product.productIdentifier] then local index = shopInfo[product.productIdentifier].index table.insert(sortedProducts, index, product) print("item "..index.." "..product.title) end end for k,v in pairs(sortedProducts) do print(k, v.title) end
Output from Working Device
Order of items from Google Play:
item 5 Pocketful of Coins
item 3 Increase Swaps
item 8 Big Chest of Coins
item 7 Small Chest of Coins
item 9 Wheelbarrow of Coins
item 4 Full Upgrade
item 6 Sack of Coins
item 1 Remove Ads
item 2 Infinite Lives
Sorted table:
1 Remove Ads
2 Infinite Lives
3 Increase Swaps
4 Full Upgrade
5 Pocketful of Coins
6 Sack of Coins
7 Small Chest of Coins
8 Big Chest of Coins
9 Wheelbarrow of Coins
Output from Non-Working Device
Order of items from Google Play:
(For some reason in a different order?)
item 8 Big Chest of Coins
item 1 Remove Ads
item 2 Infinite Lives
item 6 Sack of Coins
item 4 Full Upgrade
item 5 Pocketful of Coins
item 3 Increase Swaps
item 9 Wheelbarrow of Coins
item 7 Small Chest of Coins
Sorted table:
(Notice that elements 4 and 8 are missing)
1 Remove Ads
2 Infinite Lives
3 Increase Swaps
5 Full Upgrade
6 Pocketful of Coins
7 Small Chest of Coins
9 Wheelbarrow of Coins
Has anyone else experienced this issue?