HI, I am also interested about your first question about restore…It’s a good one
Regarding the second, can you provide some code?
Heres a working sample of code to buy and list some stuff from appstore
[code]
store = require(“store”)
local screenW = display.contentWidth
local screenH = display.contentHeight
local ScreenText = display.newText(“PRODUKT INFO:”, 50, 100, 500,400, native.systemFont, 14)
ScreenText:setTextColor(255, 255, 255)
ScreenText:setReferencePoint(display.TopLeftReferencePoint);
local StatusText = display.newText(“STATUS:”, 50, 300, 500,400, native.systemFont, 14)
StatusText:setTextColor(255, 255, 255)
StatusText:setReferencePoint(display.TopLeftReferencePoint);
function transactionCallback( event )
local transaction = event.transaction
if transaction.state == “purchased” then
print(“Transaction succuessful!”)
StatusText.text = “Transaction succuessful!”
elseif transaction.state == “restored” then
StatusText.text = “Transaction restored (from previous session)”
print(“Transaction restored (from previous session)”)
print(“productIdentifier”, transaction.productIdentifier)
print(“receipt”, transaction.receipt)
print(“transactionIdentifier”, transaction.identifier)
print(“date”, transaction.date)
print(“originalReceipt”, transaction.originalReceipt)
print(“originalTransactionIdentifier”, transaction.originalIdentifier)
print(“originalDate”, transaction.originalDate)
elseif transaction.state == “cancelled” then
print(“User cancelled transaction”)
StatusText.text = “User cancelled transaction”
elseif transaction.state == “failed” then
print(“Transaction failed, type:”, transaction.errorType, transaction.errorString)
StatusText.text = “Transaction failed, type:”, transaction.errorType, transaction.errorString
else
StatusText.text = “Unknown event”
end
– Once we are done with a transaction, call this to tell the store
– we are done with the transaction.
– If you are providing downloadable content, wait to call this until
– after the download completes.
–Uppdatera databasen och kräv en omstart av spelet!
store.finishTransaction( transaction )
end
store.init(“apple”, transactionCallback)
function loadProductsCallback( event )
print(“showing products”, #event.products)
local str = “”
ScreenText.text = #event.products
for i=1, #event.products do
local currentItem = event.products[i]
str = str … (currentItem.title … ", "… currentItem.price … " SEK, " …currentItem.productIdentifier … “\n”)
print(currentItem.description)
print(currentItem.price)
print(currentItem.productIdentifier)
end
print(“showing invalidProducts”, #event.invalidProducts)
for i=1, #event.invalidProducts do
print(event.invalidProducts[i])
end
ScreenText.text = str;
end
arrayOfProductIdentifiers =
{
“”,""
}
store.loadProducts( arrayOfProductIdentifiers, loadProductsCallback )
local buy = function( event)
if event.phase==“ended” then
store.purchase{ “” }
end
end
local restore = function( event)
if event.phase==“ended” then
store.restore();
end
end
local buyText = display.newText(“BUY”, screenW/2 - 50, 600, native.systemFont, 30)
buyText:setTextColor(18, 112, 23)
buyText:addEventListener(“touch”,buy)
local RestoreText = display.newText(“RESTORE”, screenW/2-80, 800, native.systemFont, 30)
RestoreText:setTextColor(194, 67, 11)
RestoreText:addEventListener(“touch”,restore)
[/code]
[import]uid: 81188 topic_id: 26259 reply_id: 106424[/import]