IOS AppStore in-Charge tutorial (i)

Source: Internet
Author: User

A long time ago to come up with an iOS paid tutorial, but a check on the online tutorial is too much, and some write really pretty good, I thought about it, and then saved in the draft box. As for why write it out! It's a long story, the company has a project manager recently came to ask me about the Apple payment related details, chatted with him for a long while, from the project to the official Apple payment interface to see how to view the app revenue, finally let him have some clues, but the sad urge me to continue to talk to their project programmer (really Crazy), So I decided to write a document for their project, so I'm going to finish this blog by the way!


======================================== First Part ===================================

First enter the Apple Itunesconnection (https:// itunesconnect.apple.com) Click the plus sign in the upper left corner to create a new app, click on the site will pop up an information edit box, everyone just fill up the information above click Save to have an app on Apple's app platform.


On the package ID, you need to request a AppID and Bundleid for the app in advance, as long as the application is successful and will be displayed in the selection list. If someone has questions about how to apply, please see my previous push blog, which has detailed steps. Attach link click to open link.

Here, by the way, what is this itunesconnect for? It's a platform that Apple offers to individuals or businesses to manage their apps. On this platform, developers can create, delete and manage their own apps, developers can use the app to shelves and shelves, edit app information, generate test app information, such as account number, invitation code, etc., as well as what we are going to talk about in the pay function today. Of course, his function is more than I speak of these, I roughly say the role of the platform, if you often deal with it will slowly familiar with.


============================================ Part II =====================================

Next, I'll show you how to add a paid prop, first open itunesconnect, display the following page



Select the option circled by the red circle, and then add the relevant information inside, if this step is missing, the internal purchase function will not be successful.

If you have completed the relevant bank account settings, click on your app and select "in-App purchases" in the title bar above.


Then click on the "Create new" option in the upper-left corner, as shown, to go to the next interface



This interface is to let you choose the type of consumer props, now the revision of the site is Simplified Chinese translation, so unlike before opened a look do not know which to choose, and even do not know what each representative meaning (such as when I first met, in front of the leadership is really embarrassing). It is classified into the following types:




In general, most of the project is to choose the " Expendable Project " This kind, such as the purchase of gold coins in the game, Gem balabala~, and so on, after the selection will come to this interface:


Enter the product name, product ID, and price level in the edit box shown here:

1. The product name is based on the actual meaning of your consumer props, such as "100 Jewels", "100 gold coins" and so on.

2. Product ID is more important, by the project customization, as long as the only one, like I generally use the app's Bundleid plus a suffix to express, so that both project-related and unique.

3. The price level of the words "View price list" has a corresponding description, you can follow the table in each country's currency price and rank to choose.


We continue in the next section of this page:

Select the Add language option to pop up an edit page:


Clicking Save saves will appear on the interface as follows:


The last step is to click "Choose File" to submit an apple it specifies the pixel (640*920) of the product picture, when he upload finished click "Save" button, we this second part of the Gaocheng. The items submitted will be displayed on the internal purchase page as


This is a picture I intercepted in the app that has been released, added 3 items, already passed the status of (show Green), when you just submitted, because through Apple's review takes a period of time so will show a yellow wait state, so do not worry about the product editor is wrong.



===================================== Part III ======================================

In this part, I mainly show you how to apply for a test account and use the Apple Sandbox test environment to simulate the AppStore purchase process.

Select "Users and Functions" option in Itunesconnect ~



Then select the Sandbox tester in the options in the upper left corner and click the plus icon in the upper left corner to add a test person,


Edit the corresponding content, click Save, create a test account, is not very simple ah! Of course this account if you forget the password can regenerate one, it doesn't matter.

Incidentally, do not in the official AppStore above with the sandbox test account to log in, or the consequences are serious, we must keep in mind, this account is only used in the test environment ~


===================================== Part Fourth ===========================================

And then there's the code part.

1. First add "Storekit.framework" to the project and add the header file #import <storekit/storekit.h>

2. Add" skpaymenttransactionobserver skproductsrequestdelegate " listening mechanism

The following affixed to the core of the purchase of code, on a few functions, I am not here to do more detailed explanation, you can run a crossing running a glance.

. h file

  paymentviewcontroller.h//  iappaytest////  Created by silicon on 14-10-28.//  Copyright (c) 2014 Silicon. All rights reserved.//#import <UIKit/UIKit.h> #import <StoreKit/StoreKit.h> @interface Paymentviewcontroller:uiviewcontroller<skpaymenttransactionobserver,skproductsrequestdelegate> @property ( Strong, Nonatomic) Iboutlet Uitextfield *productid; @property (Strong, nonatomic) Iboutlet UIButton *purchase;-(IBAction ) Purchasefunc: (ID) sender; @end

. m file

paymentviewcontroller.m//iappaytest////Created by Silicon on 14-10-28.//Copyright (c) 2014 silicon. All rights reserved.//#import "PaymentViewController.h" @interface Paymentviewcontroller () @end @implementation paymentviewcontroller-(ID) initwithnibname: (NSString *) Nibnameornil Bundle: (NSBundle *) nibbundleornil{self = [Super I    Nitwithnibname:nibnameornil Bundle:nibbundleornil]; if (self) {//Custom initialization} return to self;}    -(void) viewdidload{[Super Viewdidload];        Do any additional setup after loading the view from its nib.    [[Skpaymentqueue Defaultqueue] addtransactionobserver:self]; Self.productID.text = @ "Com.games.ztyxs.product_point.1";}    -(void) didreceivememorywarning{[Super didreceivememorywarning]; Dispose of any resources the can be recreated.}    -(Ibaction) Purchasefunc: (ID) Sender {nsstring *product = Self.productID.text;    if ([Skpaymentqueue canmakepayments]) {[Self requestproductdata:product]; }else{NSLog (@ "Do not allow in-program payment");    }}//Request Goods-(void) Requestproductdata: (NSString *) type{NSLog (@ "-------------request the corresponding product information----------------");    Nsarray *product = [[Nsarray alloc] initwithobjects:type, nil];    Nsset *nsset = [Nsset setwitharray:product];    Skproductsrequest *request = [[Skproductsrequest alloc] initwithproductidentifiers:nsset];    Request.delegate = self;    [Request start];    }//Receive product return information-(void) Productsrequest: (skproductsrequest *) Request Didreceiveresponse: (Skproductsresponse *) response{    NSLog (@ "--------------Receive product Feedback message---------------------");    Nsarray *product = response.products;        if ([Product count] = = 0) {NSLog (@ "--------------no goods------------------");    Return    } NSLog (@ "productid:%@", response.invalidproductidentifiers);        NSLog (@ "Products paid Quantity:%d", [Product Count]);    Skproduct *p = nil;        For (skproduct *pro in product) {NSLog (@ "%@", [pro description]);        NSLog (@ "%@", [pro Localizedtitle]); NSLog (@ "%@", [Pro LocaLizeddescription]);        NSLog (@ "%@", [pro price]);                NSLog (@ "%@", [pro Productidentifier]);        if ([Pro.productidentifier IsEqualToString:self.productID.text]) {p = Pro;        }} skpayment *payment = [Skpayment paymentwithproduct:p];    NSLog (@ "Send purchase Request"); [[Skpaymentqueue Defaultqueue] addpayment:payment];} Request failed-(void) Requests: (Skrequest *) Request Didfailwitherror: (Nserror *) error{NSLog (@ "------------------ Error-----------------:%@ ", error);} -(void) Requestdidfinish: (Skrequest *) request{NSLog (@ "------------feedback end-----------------");} Listen for purchase results-(void) Paymentqueue: (Skpaymentqueue *) queue updatedtransactions: (Nsarray *) transaction{for ( Skpaymenttransaction *tran in transaction) {switch (tran.transactionstate) {case Skpaymenttrans                                Actionstatepurchased:nslog (@ "Transaction complete");            Break    Case Skpaymenttransactionstatepurchasing:nslog (@ "product added to List");                            Break                            Case Skpaymenttransactionstaterestored:nslog (@ "already purchased goods");            Break                                Case Skpaymenttransactionstatefailed:nslog (@ "transaction failed");            Break        Default:break;        }}//Trading End-(void) Completetransaction: (skpaymenttransaction *) transaction{NSLog (@ "Trade End"); [[Skpaymentqueue Defaultqueue] finishtransaction:transaction];}    -(void) dealloc{[[Skpaymentqueue Defaultqueue] removetransactionobserver:self]; [Super Dealloc];} @end

The code is so much, to this side of our iOS shopping tutorial is nearing the end of the test, there are a few factors to note:

1. When the sandbox environment test AppStore the internal purchase process, Please use a device that is not jailbroken .

2. Be sure to test with the real machine, whichever is true.

3. The bundle identifier of the project needs to be consistent with the bundleid you fill out when you apply for AppID, otherwise you will not be able to request product information.

Speaking so much, attach a few test screenshots to show you:

Print log when requesting a product


After successful trading:



Mobile screen:

Required to enter AppStore account, use the test generated can



Confirm Purchase:



Transaction completion:



OK, all the internal purchase process is basically finished, forgive me on the image of the smear, because of the sensitive product of the word so I hope you can not mind. The time to rush this blog, if there is any question of children's shoes or I write the place is not welcome to the private message I or comment, I will reply in the first time. Thank you ~




IOS AppStore in-Charge tutorial (i)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.