What I want to do:
I want to have non consumable products and possibility to restore them without server.
Just first example with android, when all works fine. I just want to understand that I made all right.
Part 1, Let’s try to understand how it works on Android (and how it should work)
Products configuration:
On Android I have no option to set my product as non-consumable.
I just create new product and activate it.
###Steps how it works
Buy
1.
function M.buy(self, id)
iap.set_listener(iap_listener)
iap.buy(id)
end
-
local function iap_listener(self, transaction, error)
if transaction.state == iap.TRANS_STATE_PURCHASED then
msg.post(...)
--no finish!!!
end
end
Reinstall an apk
Restore
1.
function M.restore_purchases()
iap.set_listener(iap_listener)
iap.restore()
end
2 Same code as in Buy part
local function iap_listener(self, transaction, error)
if transaction.state == iap.TRANS_STATE_PURCHASED then
msg.post(...)
--no finish!!!
end
end
###Steps how it didn’t work:
Buy
- Same code for a buy
function M.buy(self, id)
iap.set_listener(iap_listener)
iap.buy(id)
end
-
local function iap_listener(self, transaction, error)
if transaction.state == iap.TRANS_STATE_PURCHASED then
msg.post(...)
iap.finish(transaction)
end
end
Reinstall an apk
Restore
1.
function M.restore_purchases()
iap.set_listener(iap_listener)
iap.restore()
end
2 . iap listener did not invoked at all (I have no non consumed items, because i finish them all)
All right there?