In-app purchases are included in applications so that you can release your app for free and if users enjoy it they can purchase more.
First, log into the iOS Developer Center.
Select Identifiers under iOS Apps and then select the App ID.
Click the + button and complete the form like the following:
Basic iOS interview Questions And Answers
Most Important iPhone interview Questions and Answers
You must create a unique Bundle ID of your own. You have to choose this Bundle ID while creating new App in iTunes Connect.
Note:
Make sure that In-App Purchase and GameKit are enabled by default.
Create In-App Purchases Product IDs
- Now,you have to set up some required In-App Products in iTunes Connect.
- You can see a button in iTunes Connect (+) , just click to add your own In-App items.
1)Consumable:
This kind of product can be purchased multiple times, and not just once.
Example:
In a game a consumable product can be a number of extra lives for the main hero.
Consumable products unlock app features just for a small period of time, and they don’t have permanent effect.
2)Non-Consumable:
This category is the exact opposite to the previous one, and as you understand the purchase of a non-consumable product is made just once.
Example:
Buying extra fonts for a text-editing app must be done just one time, and the extra fonts must be available from there on and forever.
Read:
Best Tutorials- Properties in objective C
Top 5 Simple iOS Interview Questions And Answers
NOTE:
- Generate and install a new provisioning profile on your device
- Update the bundle ID and code signing profile in Xcode
- Check that your project’s .plist Bundle ID match your App ID .
For In App Purchases, there are certain steps needed to be done in Xcode.
We have to make sure that all the required frameworks will be added to the project and that the necessary configuration will be done for us by Xcode. As you’ll see, things are simple, as in total we have to do to distinct tasks:
To enable In-APP Purchase in our project.
STEP 1:
To set a valid iOS developer account (Team -Xcode).
Starting from the second objective, open the starter project in Xcode, and once it gets launched click to the project target in the Project Navigator.
Then, in the General tab and inside the Identity section, click to the Team dropdown control and select your developer account, just as shown below.
- Open the Xcode > Preferences
- Click to the Accounts tab.
- Click to the small plus button to the bottom-left side and select the Add Apple ID.
- To the modal window that appears enter your Apple ID and password, and then click Add.
STEP 2:
Now you can follow the procedure described right above, and set a valid Team value for the project.
Next, let’s enable the IAP to our application.
While having the project target already selected to the Project Navigator panel, this time click to the Capabilities tab. In capabilities list, locate the In-App Purchase and switch it on:
What is the difference between IBOutlet and IBAction in iOS ?
Top iOS interview Questions And Answers Collection
Add SDKBOX Plugins To Your Project:
Step1:
Get Auto Installer:
Download from here.
OR
Copy and paste the script below into a terminal/prompt
----------
python -c "import urllib; s = urllib.urlopen('https://raw.githubusercontent.com/sdkbox-doc/en/master/install/install.py').read(); exec s"
OR
Or, install manually: download the plugin bundle, and checkout the sample project
Bundle file for cocos2d-x v3.x (download)
Step2:
Drag and drop the following frameworks from the plugins/ios folder of the IAP bundle into your Xcode project, check Copy items if needed when adding frameworks:
sdkbox.framework
PluginIAP.framework
Read:
Top 5 Basic iOS Questions Asked in interviews
Step3:
The above frameworks depend upon other frameworks.
You also need to add the following system frameworks, if you don't already have them:
Security.framework
StoreKit.framework
AdSupport.framework
CFNetwork.framework
SystemConfiguration.framework
Add sdkbox_config.json to your project
It carries all the Product IDs and reference names (Consumable or non-consumable).As I have added some dummy items below.You must add your own product records.
{
"ios": {
"iap": {
"items": {
"Tiny pack of coins": {
"type": "consumable",
"id": "com.cocos2dx.non1"
}
}
}
}
}
Read:
Top iOS Interview Questions And Answers for Beginners
Here is SDKBOX-Inapp-Purchase Sample Codes.zip with all of the classes ,you can download below.
Feel free to re-use the in-app purchase classes in Cocos2d-x (SDK BOX).

sdkbox-inapp-purchase_sample_codes.zip |