i set up my first in app purchase and it works fine (for the actual buying part) but i noticed that the command GetInAppPurchaseAvailable ( iID ) crashes the app if you try to use it right away (took about an hour or 2 for the app to not crash instantly if calling the command - following the example code as a guide causes the app to crash instantly on successful purchase), i assume there is a delay in google updating the records for the command to return a valid result... now my question is then; how have you (those of you who have used IAP) coded your app to confirm a purchase was completed correctly if the command isn't working?
the code i used is basically exactly the same as the example code (except im using android instead of ios).
example code
#constant true 1
#constant false 0
global iap_onoff as integer = false
global iapVies as integer = -1
global iapBombes as integer = -1
global iapMelanges as integer = -1
if (left(getDeviceName(),3) = "ios")
iap_onoff = true
// title of windows
inAppPurchaseSetTitle(getAppName())
// set up first inApp Product (id "bidioojoker" already created on iTunes Connect)
iapVies = 0
inAppPurchaseAddProductID("bidioojoker",1)
// set up first inApp Product (id "bidioobombes" already created on iTunes Connect)
iapBombes = 1
inAppPurchaseAddProductID("bidioobombes",1)
// set up first inApp Product (id "bidioomelanges" already created on iTunes Connect)
iapMelanges = 2
inAppPurchaseAddProductID("bidioomelanges",1)
// activate inApp for AGK
inAppPurchaseSetup()
endif
// ...
// somewhere in the program, to by product bidioojoker => iapVies
if (iap_onoff = true)
// inApp available on this device
txt = createText("clic to buy bidioojoker")
sortie = false
repeat
sync()
if (getPointerPressed() = 1)
inAppPurchaseActivate(iapVies)
while (getInAppPurchaseState() = 0)
sync()
endwhile
if (getInAppPurchaseAvailable(iapVies) = 1)
// product bought by the player, add your code there
else
// product not bought by the user
endif
endif
until (sortie = true)
deleteText(txt)
else
// inApp not available
endif
basically i have a button set to purchase the removal of ads so i need to check the command when the app loads so i know to show ads or not.
as i say, the app is working fine now that it's been a couple hours since the crash (the crash happened in 2 apps and 100% of the time so it's not a one-off - no changes made in this time so i know i didn't "fix" it), but obviously it's not ideal to make users wait hours to play after they just purchased an item, hopefully this is something that can be fixed in a future update
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu