Hello Everyone.
I've been working on an update for my
Night Light app. Which among other things, involves updating the Ad Removal from using the old In App Purchase commands, to using the
new In App Purchase commands which were introduced in AGKS 2021.06.14.
This is (more or less) the current code from the night light.
// Starts the buying process
InAppPurchaseActivate ( 0 )
While GetInAppPurchaseState()=false
Print("IAP in progress...")
sync ( )
EndWhile
// Write debug depending on result
If GetInAppPurchaseAvailable(0)=true
// Hides the advert!
SetBannerAdVisible(false)
// Alls good
//WriteDebug("IAP Purchased - completed OK")
FirebaseLogEvent("IAP_OK")
Else
// User cancel or fail for other reason
//WriteDebug("IAP Purchased - Called but not completed")
FirebaseLogEvent("IAP_CANCELLED")
Endif
See how it's using the decprecated command
GetInAppPurchaseState(), which now seems to have been combined with the
GetInAppPurchaseAvailable() command to produce
GetInAppPurchaseAvailable2().
After some searching, and scouring the forums, the help and all the examples/guides; I finally came up with the following to replace it.
InAppPurchaseActivate(0)
Repeat
iapStatus = GetInAppPurchaseAvailable2(0)
Select iapStatus
// Cancelled? The IAP was cancelled by the user
Case 0:
// Break out of loop
finished = true
Endcase
// IAP Queued
Case 1:
Print("IAP in progress..")
Endcase
// IAP In progress
Case 2:
Print("IAP in progress..")
Endcase
// IAP Pending
Case 3:
Print("IAP in progress..")
Endcase
// IAP Completed
Case 4:
// Award the IAP
` do something here
// Break out of loop
finished = true
Endcase
EndSelect
sync()
Until finished = true
The problem is, this code cannot be tested from the player, it needs compiling into an .apk and uploading to Google Play. So in the mean time, I thought I would ask on here for any advice? Or if I have made any obvious mistakes in the second snippet above.
Thanks in advance