Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to add in-app purchase in your games.a step by step tutorial.

Author
Message
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 21st Nov 2011 03:53
1. First of all , you should create your products in iTunes Connect. Login into the iTunes Connect,click Manage Your Applications, click the application which need in-app purchase, then in your application page,click manage in-app purchase, then click create new. I think this step is very easy for you.

2.second, create your own store observer.
MyStoreObserver.h

MyStoreObserver.m

you should pay attention to this method : - (void) completeTransaction: (SKPaymentTransaction *)transaction. I added my own function to provide the product in my game.
when the users pay for products successfully ,the store observer will call updatedTransactions to change the state to SKPaymentTransactionStatePurchased. you can add your own code here. g_View is global variable for untitledControlView. RemoveAdsPurchased is my own function. I did two things in it.one is recode the state, the other is hide the ads in my game.

3. the third step. you should add four function in the untitledControlView.m

kMyFeatureIdentifier is the product id which you defined in the iTunes Connect.It's very important, so you should change it to your product id. you need not to make a change to the other three function, basically, they are just common for every apps.

4. the last step. You call PayforRemoveAds function when the user tap the button which you designed.the function name is not important, you can change it to your own.

then, when the user tap the purchase button, the app store UI will come out. That's all.
If you have any questions, you can post here followed this thread. I'll answer as quickly as I can.

Halley
from Miracrea Games.

The Miracrea Games
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 21st Nov 2011 09:06
GREAT Tutorial!

Thanks a lot HALLEY
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 21st Nov 2011 09:08
@bjadams : you r welcome!

The Miracrea Games
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Nov 2011 12:51
Nice!

This tutorial would be a great addition to the ADG website resources. Do you mind if we add it?

halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 21st Nov 2011 12:58
@baxslash , I don't mind. As your wish.

The Miracrea Games
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Nov 2011 13:00
Thanks! I'll try to add it soon and let you know when it's done.

halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Nov 2011 04:08
@baxslash : you can use any tutorial of mine as your wish.

The Miracrea Games

Login to post a reply

Server time is: 2024-03-29 10:56:53
Your offset time is: 2024-03-29 10:56:53