Salad Solutions is a compilation of educational resources developed by the GameSalad team. Resources include: webinar videos, Question of the Week answers, and Cookbook highlights.
In today's Question of the Week, our staff explores the most commonly received questions (via GameSalad forums and customer support) surrounding the use of In App purchase and has created a "Best Practices" guide for your use.
Question of the Week: In App Purchase Best Practices
Here are a handful of best practices that are key to using In App Purchase (IAP) successfully:
• Your Product ID in GameSalad Creator must be typed exactly the same as your Product ID on the iTunes Connect website (It is case sensitive).
• We recommend avoiding the use of Expression Editor for values that don't gain a tangible benefit from it, as the Expression Editor requires that some values be enclosed in quotes. Using the Expression Editor without quotes around these values can result in behaviors being improperly configured.
• Your Success, Cancel, and Error scenes must include an Unpause Game behavior, since they act similarly to paused scenes. If you choose to use the "Don't Change" scene option, it will simply resume where the player left off in the current scene.
• To test IAP on an ad-hoc build, you'll first need to create an IAP Test User account, by selecting Manage Users at https://itunesconnect.apple.com
• For GameSalad's original IAP guide, click here: http://cookbook.gamesalad.com/tutorials/5/parts/26
• For Apple's documentation regarding In App Purchases, click here: https://itunesconnect.apple.com/docs/iTunesConnect_DeveloperGuide.pdf
Q: How do I use IAP to unlock an ad-free version of my game?
In iTunes connect, make sure you choose "Non-Consumable," as you don't want the user to have the ability to accidentally re-purchase something that they should only have to buy once.
In GameSalad Creator, create a Boolean game attribute called "game.UnlockGame". Add an iAd behavior to any appropriate scene within a rule with the condition "if game.UnlockGame=FALSE". Then set up an IAP that will unlock the game, which will change "game.UnlockGame" to true when the purchase is successful. What this will do is show ads on scenes when the game in not unlocked, and remove them when the IAP is bought.
Q: I noticed that there is no "Change Attribute To:" field for Non-Consumable item purchases. Should I assume that boolean attribute I provide will be changed from false to true?
You are correct. IAP will automatically change a Boolean attribute to true for Non-Consumable item purchases.
Q: With IAP, do I need to add a Save Attribute behavior so that the game doesn't forget the purchase, or is this handled automatically?
For Non-Consumable purchases, the changed boolean attribute will be automatically saved as true. However, you will need to put a Load Attribute behavior in your initial scene that utilizes the ProductID of the IAP as the Key.
Consumable Items are a little different. You cannot use their product ID as the Key for a Load Attribute behavior in the same manner as a Non-Consumable boolean attribute. The reason is the player will likely be using the consumable item constantly. In the case of a coin pouch that increases coin count, the player will probably spend coins all the time on in game items and upgrades. We suggest adding a Save Attribute behavior to any event in your game where you consume or modify your item with a unique Key, such as "TotalCoins" as opposed to the product ID. Then you can add a Load Attribute behavior at the beginning of your game with your unique key that will load an accurate coin count.
Q: I'd like to use the In App Purchase Restore Item Action behavior by adding it to a button actor, so that the player can recover their purchases if they encountered hardware failure or delete/reinstalled the app . How is this handled and can I use this for both Non-Consumable and Consumables?
For Restoring, what should happen is communication opens up with Apple, similar to a purchasing event. If you only bought 2 of 10 items, only those 2 will be unlocked, while the other 8 are ignored since Apple's database will know you have not purchased them. No additional messaging should be seen by default -- however you can always create your own game logic around this if you'd like added visibility.
Then, any unlocked Non-Consumable purchase attributes will be saved automatically like a purchase event. It is still best practice to include a Load Attribute behavior in your initial scene associated with your purchases.
And as you may have guessed, consumables cannot be restored.
Q: Can I use the In App Purchase Item behavior to change multiple game attributes instead of just one?
It's doable, but requires that you create logic that triggers these additional attributes changes. However, it is not recommended as it could get very messy if miss-configured or abused.
Q: What is the IAP process for testing and using sandbox? More specifically, describe how iTunes Connect and the App speak with each other and whether (and how) it works with AdHoc builds.
Apple's IAP servers talk to your game via the app bundle identifier associated with it. If you set up a new app on iTunesConnect and specify a bundle, this is what gets looked up at the time of the purchase. Every IAP item you set up on the Apple side will be associated with this bundle as well. In order to properly test this in Sandbox Mode publish an AdHoc build of your project with the IAP properly linked via the Product ID per item. This will ping Apple's sandbox server and allow you to simulate purchases using a test user account that you set up through iTunesConnect as well (covered in the Cookbook documentation).
Additionally, your app and items do not have to be approved by Apple in order to test ad hoc builds. Your IAP will not be submitted for review until you submit a binary.