IOS purchase -iap-In-App Purchases- development and precautions

* pit records, and later found that some of the unusual pit may be updated

1 occurs in the first submission of app or adding new products, when you app through the audit, you find in the production environment to obtain goods, although this is because the app audit, but in the purchase of goods has not yet officially added to Apple’s servers, you can wait a long time.

2 I created IAP goods, when I don’t want to delete, that could not be deleted after I click the delete button, the page will automatically refresh, refresh the back, the goods still exist, I changed the N browser, mobile phone browser even tried, is not, no way can only be submitted for review, and then Apple said they couldn’t give me feedback to me this product where…… solution: audit statement from apple in additional, best record a video uploaded to the website (Youku can), the video address to follow Apple: at that time had complaint, but because Apple only to registered developers the mail account information, and the boss every day in the company, so the final communication interrupted with apple. I will transfer the account after the App, the Bug disappeared, I do not know whether the account is transferred or apple fixes.

A: IAP development

The specific development process is not too much to write, too many online, just casually Baidu has a few pages, here only to recommend a library, it is very convenient to use
download address: IAPHelper

NSSet* dataSet = [[NSSet alloc] initWithObjects:@ "here is the IAP merchandise ID, nil]; [IAPShare sharedHelper].iap = [[IAPHelper alloc] initWithProductIdentifiers:dataSet]; / / [[IAPShare sharedHelper].iap requestProductsWithCompletion:^ request product information (SKProductsRequest* request, SKProductsResponse* response) {if (response.products.count > 0) {SKProduct *product = response.products[0]; [[IAPShare sharedHelper].iap buyProduct:product onCompletion:^ (SKPaymentTransaction* trans) {if (trans.error) {else} if (trans.transactionState = = SKPaymentTransactionStatePurchased) {/ / to buy here is a success, but because of the existence of mobile phone jailbreak download some software to break the purchase The situation, need to confirm whether the apple server provides the successful purchase / / IAPHelper method, the verification step can be written on the front, can also write on the server side, the own decision ### / /..!! There is a situation that needs attention. Program came here, it is already a state of payment success. The user ### / / money has been deducted the apple, then need to do is to verify the purchase information. ### / / but if successful purchase ',' intermediate verification orders' problems', broken network, App crashes and other problems, there will be deducted the money but recharge failure situation ### / / so here can be below the authentication information stored locally, then deleted successfully. Validation fails, the information can be taken out to verify the NSData *receipt verification / buy = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] every time App starts; / / the Raiders are old, used in the validation of trans.transactionReceipt, need to pay attention to the trans.transactionReceipt was abandoned after ios9 [[IAPShare sharedHelper].iap checkReceipt:receipt onCompletion:^ (NSString *response, NSError *error) {}] else if;} (trans.transactionState = = SKPaymentTransactionStateFailed) {if (trans.error.code = = SKErrorPaymentCancelled) {}else if (trans.error.code = = SKErrorClientInvalid) {}else if (trans.error.code = SKErrorPaymentInvalid) }else {if (trans.error.code = = SKErrorPaymentNotAllowed) {}else if (trans.error.code = = SKErrorStoreProductNotAvailable) {}else{}}}]; / /}else{. Without access to goods}]};

On the development of the purchase of these on the Internet, perhaps more Raiders Raiders, you will probably be able to write out the search, IAP although it is not difficult to develop, but there are too many pits inside Mad Fake…

Two: IAP Development Notes

1 what conditions need to use IAP, what situation the use of three party payment

Here is my understanding:

Things are purchased in kind, does not exist in APP, with three party payment, such as Taobao, a pile of electricity suppliers, their products are not present in the App. If you pay and buy in order to unlock the function of App, we must use IAP, that is, the purchase

For example: there are many online education App, such as the NetEase Tencent cloud classroom, classroom, can buy and watch video in App in APP, that is to say ‘Watch Video’ this is inherent in the APP, you just need to buy video to use ‘watch this function video’ this time, the APP have the function of unlocking operation, it is necessary to use the IAP

2 on the type of goods: IAP to create goods when you choose the type of goods may be divided into three categories

IOS purchase -iap-In-App Purchases- development and precautions
1 consumable goods:

A similar game of diamonds, and now some APP currency, such as fish in fish, Ying Ying in the passenger ticket. Will be consumed, to choose the consumption of goods

2 non consumable goods:

Can not be consumed goods, such as the video courses mentioned above, a purchase, it should be able to permanently Watch

3 subscription types:

More for members, members can also be made with the use of consumer goods to obtain the money to buy now can not do, before the submission of a lot of things are okay, perhaps the previous members of the function of the existence of a sense of low audit team did not find? Or is the latest version of the new regulations, submit for this reason is rejected, error description:
Business – 3.1.1 We noticed that your app is using Consumable In-App Purchase products as intermediary currency for the exchange of items that function as Non-Renewing Subscriptions.

To mention here a point: if your company is an outsourcing company, a subscription type APP merchandise must be with the customer’s account submitted for review, because when APP had a subscription type goods, pay attention to have been created, and then delete the APP too, cannot be transferred account

3 note

1 when you use consumable goods

Most of the consumable items need to be logged in because they need to keep the balance in the database.
need to pay attention to is: before login, you’d better not let the user see the goods, may be rejected for this reason (see luck), chestnut:

IOS purchase -iap-In-App Purchases- development and precautions

As above. This is the recharge page, which is the product page.
you have two choices:

# 1 tourists buy, namely the user to click on the page to recharge, recharge, even if the user does not log in, can also recharge # 2 let the user is not logged in to recharge page. And must be selected by the user. There is a button, click the recharge page, when the user is not logged in click on the button, you must pop-up selection box, selected by the user's login / registration or cancellation, and explain the situation as follows:
IOS purchase -iap-In-App Purchases- development and precautions
2 when you use non consumable goods

When you use a non consumable goods, you need to add a
button to buy this recovery is common in a variety of games, in fact, know this is good after understanding, non consumption of goods is not be consumed, and buy a lifetime use, non consumption type of goods with appleId binding that is what you usually download APP lets you enter the account password in a.
you need a button to restore the purchase, to allow users to restore the contents of his purchase, the above IAPHelper also have this method, look at their own

3 subscription goods

APP can not be used or used to subscribe goods

In the apple help, one of the categories is: what kind of APP can be transferred
I see, in full compliance with the ah, and then, through development, submitted to the audit, but when I was at the time of transfer TM tips I can’t transfer again when I go back to the bottom of the page for help, when
found drop down on the other a: why can’t I classification APP transfer……

IOS purchase -iap-In-App Purchases- development and precautions