• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

iOS Restore in-app purchases

GameDevDan

Former Jam Host
Moderator
GMC Elder
iOS requires that developers provide a way to restore in-app purchases, and GameMaker: Studio provides a handy function to do just that: iap_restore_all();

The only problem is, I don't have a clue how it works.

The official documentation says it adds a key to the iap_data ds map which returns whether or not restoration was successful. But there is nothing in the official docs, or on the helpdesk, that explains how you can then use that information to check whether a specific item has been purchased and act accordingly.

For example, I have an IAP I want to add to my game called "removeAds". When the IAP has been purchased it sets the variable global.ads to 0, and no adverts will be shown in the game.

How do I go from calling iap_restore_all to something like this:

Code:
if ( removeAds was previously purchased ) {

  global.ads = 0;

} else {

  global.ads = 1;

}
 
P

PixelApe

Guest
I'm guessing you figured it out since it's been 3 months :). Well, if not and someone else looking for the same thing.

Just add logic to receipt of iap_ev_restore in the social event, just like you would have handled iap_ev_purchase & iap_ev_consume while implementing the IAP purchase .
 

PNelly

Member
Went through the same thing you're going through now.

What happens is you'll receive multiple separate IAP events. The iap_ev_restore (or whatever it's called) will only contain a flag stating whether the process was successful or not. Additionally you will receive an iap_ev_purchased (or whatever it's called) for each restored product, in exactly the same fashion as happens when a user makes the initial purchase.
 
T

thaaks

Guest
IIRC that's all explained in Nocturne's InApp tutorials for the mobile platforms, including coverage of restoring purchases on iOS.
http://www.yoyogames.com/blog/74 covers the restore stuff for Apple stores.
And this is a very helpful article with example code.
 
Top