Working on allow general saved data to be retrieved in my app, both for game saves and storing whether the in-app purchase has been made.
I am following the guidlines here https://lessons.livecode.com/m/4069/l/1 ... e-appstore and have inputted the code as described:
Code: Select all
on preOpenStack
loadNonConsumablePurchase
end preOpenStack
on loadNonConsumablePurchased
local tPath
put specialFolderPath("documents") & "/nonconsumablepurchased.txt" into tPath
if there is a file tPath then
set the cNonConsumablePurchased of this stack to url("file:" & tPath)
put "PURCHASED" into fld "purchased" of cd "playmodes"
end if
end loadNonConsumablePurchased
setProp cNonConsumablePurchased pValue
set the cNonConsumablePurchased of this stack to pValue
if pValue then
put "PURCHASED" into fld "purchased" of cd "playmodes"
else
put "NOT PURCHASED" into fld "purchased" of cd "playmodes"
end if
saveNonConsumablePurchased
end cNonConsumablePurchased
on saveNonConsumablePurchased
put the cNonConsumablePurchased of this stack into url("file:" & specialFolderPath("documents") & "/nonconsumablepurchased.txt")
end saveNonConsumablePurchased
on purchaseStateUpdate pPurchaseID, pProductID, pState
switch pState
case "paymentReceived"
answer "payment received!"
offerPurchasedProduct pProductID
mobileStoreConfirmPurchase pProductID
mobileStoreDisablePurchaseUpdates
break
case "error"
answer "Error occured during purchase handling:" & return & return & mobileStorePurchaseError(pPurchaseID)
mobileStoreDisablePurchaseUpdates
break
case "invalidSKU"
answer "Invalid SKU."
mobileStoreDisablePurchaseUpdates
break
case "alreadyEntitled"
answer "Already Owned."
mobileStoreDisablePurchaseUpdates
break
case "restored"
answer "restored"
offerPurchasedProduct pProductID
mobileStoreConfirmPurchase pProductID
mobileStoreDisablePurchaseUpdates
break
case "cancelled"
answer "Purchase Cancelled:" && pProductID
mobileStoreDisablePurchaseUpdates
break
end switch
end purchaseStateUpdate
on offerPurchasedProduct pProductID
if pProductID is "FullGame" then
set the cNonConsumablePurchased of this stack to true
end if
end offerPurchasedProduct
However, when I quit the app and load it back up, I dont see "purchased" as I should, since I've asked it to check for the txt file and then put that into the field once found.
Any ideas?