iOS app development within the purchase

Source: Internet
Author: User

    • Inside Purchase Simple Introduction
    • Configure itunes Connect
    • Iosclient Development work

First, inside purchase simple introduction

1?? There are three main ways to make money through the Apple App Store: Direct charges (contrary to the consumption habits of most domestic users). Assuming direct charges, do not set to $6) – Advertising (reduced user experience, many in Android systems, few in the Apple system) – buy within 2?? Category: Non-consumable (nonconsumable) – refers to an item or service that is purchased once in the game and has permanent access. Non-consumable items can be downloaded again by the user and can be used on all users ' devices. Consumables (consumable) – Designed to support consumable items or services, consumables purchases cannot be downloaded again. According to its characteristics. Consumables cannot be used across devices between users ' devices, unless they are defined to share the information between users ' accounts? The following three categories are used in ibooks, and ibooks does not support the mainland market at the moment – free subscription (subscriptions) – Self-renewal Subscription (auto-renewing subscriptions) – Non-Self renewing subscription (nonrenewing subscriptions) Second, configure itunes Connect1?? Create your own app (no need to sue, no app how to buy inside) 2?? After you create an in-app paid item, set the price and Product ID, as well as the purchase description, and the product ID is the one you need to remember. It needs to be developed later. 3?? 4 of test users added to the sandbox pay?? Fill in the relevant tax. Bank. Contact information Three, iosclient development This picture is very clear explanation of the whole process of internal purchase, mainly consists of the following steps (I hope you look at the details of this picture, to understand the internal purchase process)? Request a valid product code set? Purchase a specific product? Buy a purchase? Restore Purchase 1? Request a valid Product code set
// 1) Instantiate the product request skproductsrequest *request = [[skproductsrequest alloc]initwithproductidentifiers: Identifiers]; // 2) Set agent [request setdelegate:self]; // 3) Start request [ask start];

Tips:

1. When the request is instantiated. You must specify a valid identifiers collection. The reason why this is handled. Mainly to ensure that the submitted in the purchase of goods really through the Apple's approval, in a usable state!

2. To obtain an accurate collection of available products. Need to be implemented by proxy method

-(void) Productsrequest: (skproductsrequest *) Request Didreceiveresponse: (Skproductsresponse *) response

3. Jailbreak users cannot test in-store, but can buy

2?? Buy Products

1. The transaction process of internal purchase is monitored through skpaymenttransactionobserver. It is therefore necessary to join the trading observer for Iaphelper:

// Join the Trader Observer object [[Skpaymentqueue defaultqueue]addtransactionobserver:sharedinstance];

2. The Skproduct object is required for initiating the transaction. Therefore, you need to use a dictionary to record all available items

Nsmutabledictionary         *_productsdict;

3. Transaction queue callback method

- (void) Paymentqueue: (Skpaymentqueue *) queue updatedtransactions: (Nsarray *) transactions{ for(Skpaymenttransaction *transactioninchtransactions) {        //Purchase Complete            if(Transaction.transactionstate = =skpaymenttransactionstatepurchased) {NSLog (@"Purchase Complete%@", Transaction.payment.productIdentifier);        [Queue finishtransaction:transaction]; } Else if(Transaction.transactionstate = =skpaymenttransactionstatefailed) {            if(Transaction.error.code! =skerrorpaymentcancelled) {NSLog (@"trade failure:%@", transaction.error.localizedDescription); }        }    }}

3?? Validate purchases (usually done by server)

    1. Receive proof of purchase from the iOS side.
    2. Infers whether the credential already exists or has been validated, and then stores the voucher.

    3. Send the credential to Apple's server validation and return the validation results to the client.
    4. Assumptions required. Change the user's corresponding member privileges.

Take into account the network exception condition. The validation of the server should be a recoverable queue. If the network fails, it should be retried.

The authentication interface document with Apple is here.

In a nutshell, the purchase voucher is encoded with Base64 and then post to the Apple authentication server, and Apple returns the validation results in JSON form.

The verification address of the purchase voucher on the Apple AppStore line is https://buy.itunes.apple.com/verifyReceipt, and the verification address of the test is: https://sandbox.itunes.apple.com/verifyReceipt

4?? Restore purchases-Recover all products purchased by users

[[Skpaymentqueue defaultqueue]restorecompletedtransactions];

iOS app development within the purchase

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.