iOS app development within the purchase

Source: Internet
Author: User

    • Inside Purchase Introduction
    • Configure itunes Connect
    • iOS Client development work

I. Introduction of Inside Purchase

1?? There are three main ways to make money through the Apple App Store: – Direct charges (contrary to the consumption habits of most users in the country, if directly charged, do not set to $6) – Advertising (reduced user experience, very much on Android system, very little in the Apple System) – Buy 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 devices of the user? Consumables (consumable) – Designed to support consumable items or services, consumables purchases cannot be downloaded again, and, according to their characteristics, consumables cannot be used across devices between users ' devices, Unless the custom service shares this information between users ' accounts? The following three categories are used in ibooks, currently ibooks does not support the mainland market – Free subscription subscriptions – Auto-Renew Subscription (auto-renewing Subscriptions) – Non-auto-renew 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, and the purchase description and then, the product ID is to be remembered, which is needed later in the development. 3?? Add sandbox paid test users 4?? Fill in the relevant tax, bank, contact information third, the iOS client development This diagram clearly explains the whole process of internal purchase, mainly including the following steps (I hope you look at the details of this picture to understand the internal purchase process)? Request a valid Product code collection? Buy a specific product? Purchase a 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 instantiating a request, you must specify a valid identifiers collection, and the reason for this is to ensure that the submitted in-store product is actually approved by Apple and is in a usable state!

2. To obtain an accurate collection of available products, a proxy method is required to achieve

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

3. Jailbreak users cannot test for in-store purchases, but can purchase

2?? Buy Products

1. The transaction process of the purchase is monitored through skpaymenttransactionobserver, so it is necessary to add the trading observer for Iaphelper:

// add a Trade watcher object [[Skpaymentqueue defaultqueue]addtransactionobserver:sharedinstance];

2. Because the Skproduct object is required for initiating a transaction, it is necessary 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 the server)

    1. Receive proof of purchase from the iOS side.
    2. Determine if the credential already exists or has been validated, and then store the voucher.
    3. Send the credential to Apple's server for authentication and return the validation results to the client.
    4. If necessary, modify the user's corresponding member permissions.

Given the network anomalies, the server's authentication should be a recoverable queue and should be retried if the network fails.

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 for the purchase voucher on the Apple AppStore line is https://buy.itunes.apple.com/verifyReceipt, and the verified address for the test is: https://sandbox.itunes.apple.com/verifyReceipt

4?? Restore purchases-Recover all items 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.