Written with Obj-C
At the heart of this tutorial are two classes written in Objective-C, an In-App Observer and In-App Manager class, which handle listening for purchases and reacting to them. These two classes can be imported to any of your existing projects. Like all our tutorials, you’ll get the source code to copy and paste from.
Sprite Kit Examples...
While this isn’t exactly a Sprite Kit course, we teach you how to integrate the in-app purchasing classes into a Sprite Kit based project. So you’ll finish the course with two example projects, one using UIViews and one using Sprite Kit.
Learn more about your instructor...
This course is taught by Justin Dike, owner and lead developer at CartoonSmart.com, creator of the Fantastic Worlds iOS Starter Kits, and author of iOS Game Programming with Xcode and Cocos2d (published by Focal Press). Justin has been programming iOS games since the release of the first iPhone and has been teaching development for just as long, covering mostly game related topics. He’s proficient with Cocos2d, Sprite Kit, Objective-C and most recently Swift.
Set up In-App Purchasing in any of your iOS Apps!
If you want a step-by-step understanding of how to create an InAppManager and InAppObserver class, this is the course for you!
If you don’t care about creating those classes from scratch and just want to jumpstart into using in-app purchases, this is ALSO the course for you. You’re welcome to skip ahead to the Quick Start guide (and copy our InAppManager and InAppObserver classes). You can begin testing purchases or creating an in-game money system within an hour.
Included with the tutorial movies are two source projects, one uses the Sprite Kit template and another uses the starting template for Single View Application. These projects alone make for a valuable reference, but you’ll get three hours of tutorials explaining every detail!
Four sessions to get you up and running. Or you can skip to the quick start guide.
Session 1 – iTunes Connect Setup and Provisioning
- iTunes Connect Setup – 9:14 – An introduction to this tutorial on consumable and non-consumable purchases and how to initially set them up in iTunes Connect. You can watch this video first or second. It is listed first since its a bit more interesting than the one on Provisioning Profiles.
- Provisioning Profiles – 6:30 – A quick look at how to create your provisioning profiles and App ID (or Bundle ID) which will need to be specified in the Xcode Project.
- Creating an iTunes Connect Test User – 1:58 – A short video on creating a test user in iTunes Connect. You’ll use this account to purchase your In-App Products without actually spending money.
- Initial Xcode Setup – 5:13 – In this short lesson we will look at adding your Bundle Identifier to the project and where your Provisioning Profiles reside in the preferences section of Xcode 5.
- Two Paths to Go From Here – 1:09 Video 5 – From here you can choose to follow along, step by step, in creating the InAppManager and InAppObserver class, or you can choose to jump ahead (using the pre-written classes from the example project) and learn how to integrate the classes with the Quick Start videos in Section 3.
Session 2 – Writing the In-App Purchasing Classes from Scratch
- Initializing the InAppManager Class – 19:38 – In this video we will import the StoreKit framework, create the InAppManager class (and InAppObserver class, though we don’t use it yet), then begin to initialize the InAppManager as a singleton. Have your In-App Product ID’s ready which you should have already setup in iTunes Connect.
- Requesting Product Data – 13:50 – In this tutorial we will populate our purchaseableProducts array with the in-app products from the App Store we created earlier. It is highly recommended you begin testing on your actual device at this point. By the end of this lesson you should receive back data from the store for each product (localized title, price, ID).
- The InAppObserver Class – 12:49 – In this video we will write the InAppObserver class which is a rather etheric class, used to simply “observe” transactions and call methods based on the result (whether a transaction is restored, completed, or cancelled).
- The Buy Products and Provide Content Methods – 13:37 – In this video we will write methods in the InAppManager class to handle buying our products and providing content afterwards. NSNotifications will be called (but received later in the Quick Start section) to handle unlocking actual content.
- Failed and Restored Transactions – 6:43 – In this tutorial we will finish up our InAppManager class and write the methods used to deal with failed transactions and restoring transactions.
Session 3 – Quick Start Guide to using the In-App Purchase Classes
- Adding the (pre-written) InAppManager and InAppObserver Classes to your project – 8:00 – In this video we will import the already-written InAppManager and InAppObserver classes to a different project, then add the StoreKit framework to that new project, as well as initiate the singleton. We will come back to this project later to add buttons to purchase particular products.
- Adding More Product ID’s to Purchase- 8:52 – In this video we will add extend the InAppManager class to use more product ID’s. This is optional viewing if you only have 1 or 2 in-app purchases.
- Adding UIButtons to Purchase and Getting NSNotification feedback – 20:52 – In this tutorial, we will add two UIButtons (to our Sprite Kit scene). Each button can be used to buy the in-app purchase OR make use of it by calling a different method if the purchase has already been bought. We will also vary the button’s title if the purchase has already been made or not. And we will receive NSNotifications in this class now to do something when the purchase has been made (or restored).
- Setting Different Button Values for the iPhone and iPad – 7:40 – In this video we will look at styling and placing the buttons differently for the iPhone or iPad.
- Using a UIView for the UIButtons (instead of a Sprite Kit Scene) – 9:32 – In this video we will quickly take the UIButton code from the Sprite Kit Based project, and create a new UIView (called AnyOldView), add it from the ViewController and display our purchase screen that way.
Session 4 – What To Do After a Purchase
- Creating an In-Game Monetary System for Consumable Purchases – 21:27 – In this tutorial we will mostly look at what to do for Consumable purchases, by creating an in-game monetary system. We will create a variable for using purchased “coins”, and a hypothetical catalog of products that could be unlocked using those coins. Using the same UIButtons created in the last section, we can purchase multiple increments of 10,000 coins and save our in-game money to the NSUserDefaults to use anytime.
- Don’t Forget the Restore Button (I almost did!)- 1:36 – If you plan to sell Non-Consumable purchases be sure to include a Restore button in the project.
- About The Source Projects – 0:54 – Included is a version using the Sprite Kit template and another using the template for Single View Application (this one includes a UIView class to contain the UIButtons). The Sprite Kit template has some extra code for handing consumable purchases.
After your purchase, you’ll always have the know-how to…
- Choose between Consumable and Non-Consumable Purchases.
- Write your own in-app purchasing classes.
- Copy pre-written classes from either a Sprite Kit or UIView project if you want to save time.
- Add notifications to tell ANY class that a purchase was made.
- Create buttons that tell buyers they’ve already purchased an item. Or prompt them to buy more.
- Create an entire in-game monetary system using consumable purchases
Like all our tutorials, you get the finished Xcode projects from the course, which have been been tested with Xcode 6.1
Two affordable purchasing options, both with social-sharing discounts.
Purchase Option 1 - Lifetime Access
Get Lifetime Access to this course for a one-time purchase price. You can download (or stream) the movie files and download any source projects.
Already have Lifetime Access? You can get started watching the video tutorials from right here.
Purchase Option 2 - Subscription Access
Get access to this course and dozens more through the CartoonSmart Subscription. Stream videos from any of your devices and download any source files / projects.Browse All Courses [edd_social_discount id=”62303″]