Powered by
Powered by
HuntMyIdeas-Inspire You To Make It Happen
Follow
   Me
  • Blogs
  • About Me
  • Home

In-App Purchase Tutorial in Cocos2d-x using SDKBOX

2/25/2016

0 Comments

 
Picture
In this tutorial ,you will learn very simple steps how to use in-app purchase in your applications  using cocos2d-x (SDKBOX).

Here are some steps that needs to be implemented before rushing into the code.
Here I have implemented this tutorial using
cocos2d-x 3.4.1.
This is a vital  things for being being an iOS developers is that there is a very  good way they can use to make money off of your apps, including in-app purchases.

​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.
Create a unique App ID

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:


Picture
Read:
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.
​
Picture
You will get to a screen that lets you select the type of In-App Purchase you want to add. Note that there are are two types of frequently-used In-App Purchases:

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:
  1. ​​Generate and install a new provisioning profile on your device
  2. Update the bundle ID and code signing profile in Xcode
  3. 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.
Picture
In case you haven’t added your developer account to Xcode yet and you can’t find it in the above control, then follow these steps:
​
  1. Open the Xcode > Preferences
  2. Click to the Accounts tab.
  3. Click to the small plus button to the bottom-left side and select the Add Apple ID.
  4. To the modal window that appears enter your Apple ID and password, and then click Add.
Picture


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 o
n:
Picture
Read:
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
Step4:

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
File Size: 820 kb
File Type: zip
Download File

0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Enter your email address:

    Delivered by FeedBurner

    RSS Feed

    Archives

    December 2019
    August 2018
    January 2018
    December 2017
    November 2017
    October 2017
    August 2017
    April 2017
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014


    ​​Categories

    All
    Affiliate Marketing
    Alexa Rank
    Apple's Latest Updates
    Blog Tips
    Cocos2d X
    Cocos2d-x
    Google AdSense Tips
    Grab-some-ultimate-ideas
    How-to-create-a-twinkling-star-background-effect-in-ios
    In-App Purchase Tutorial In Cocos2d-x (C++) Using SDKBOX
    Ios Interview Questions And Answers
    IOS Multiple Choice Questions And Answers
    Objective C
    Online Business
    Python
    Secrets To Effective IPhone App Marketing
    SEO Tips
    Swift Interview Questions
    Swift Tutorials
    Top 10 Articles Objective C
    Top 10 Articles-Objective-C
    Top 10 Popular Movies Ever
    Top 10 Popular Things To Know
    Top 10 Ultimate Issues Xcode
    Top 400 IOS Interview Questions
    Top IOS Sample Projects To Learn From
    Top Secrets To App Marketing
    UICollectionView
    Unity 3D
    Xcode

WELCOME TO HUNTMYIDEAS

Picture
I am Jitendra Gochhayat,an iOS Developer,Designer,blogger,
​from Odisha,India.
I write about ​​​blog tips and,
Make money online Tips,
​Objective C tutorials
SUSCRIBE TO NEWSLETTER

    Subscribe to this blog and receive notifications of new posts by email

Suscribe
Picture
Picture
Picture
Picture
Picture
HuntMyIdeas-2016 Powered By Weebly
Picture
Powered by Create your own unique website with customizable templates.
Powered by
Powered by