Those pits in iOS purchases (IAP)

Source: Internet
Author: User

The company's public library originally did not have this part of the code, previously done in-store is a two more famous third-party library on GitHub. A call Mkstorekit, another called Iapmanager, I read a bit of writing are very spicy chicken, it is very inconvenient to use, and writing is not right ...

So I wrote a, the beginning of writing is not very good, by the above two garbage storage (the two library interface is used postnotification), the use of listening to events, the following little brother Spit Groove said not very useful.
So I re-made an interface for the block version, the feeling is still good to write. This is very comfortable to use!

Although there are several good libraries on GitHub, but they can learn a lot of things, but also found some of the inside of the function of the pit, on- line subscription-based purchase of third-party library almost all fell into the pit! Direct use is going to be a problem!

1. Subscription in-purchase
The original two third-party library one is not processing subscription-based purchase (in fact, the basic online is not processed), Mkstorekit has this function, unfortunately, does not write to = =, there are two of local processing is problematic.

The first problem is when judging the time, using [NSDate Date] to get the user's native time. This approach has a bug, as long as the user changes to the machine time can be used to continue to use = =
The correct approach is to network access to the server time, based on server time, to prevent users from cheating.

The second issue is the use of jsonresponse[@ "Latest_receipt_info" when acquiring time, and this interface is not very good.
It's usually the last one (the latest purchase record) is what we want, but if there are multiple products this interface is very stiff!
For example, there are two different classes of goods A and B. Bought a, the last record is a, then the network is not good to verify the failure. Then the user buys B, and the last record becomes the record to buy B, and at this point there is no way to verify a.

2. Non-subscription in-purchase

Basically, there is no processing of subscription-type in-line purchase. This is no pit, online this kind of code simple and all, experience is interface do not write notification this, write block this will be useful, here say a small optimization:

The actual use will find that Apple's network response is sometimes slow, the user thought not to press will be more than a few times. The code on the web is almost always a few windows, the user experience is poor. I made a mark on this side, and if the user has a short time to connect to the same purchase request, it will be counted only once. Of course, it is also a practice to prohibit user interaction when the original request is not completed, but after a colleague uses it, it is too cumbersome and easy to forget when it is too late to do so, and finally uses the method of marking in the manager.

Those pits in iOS purchases (IAP)

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.