Author: ChengzhiHuang, iOS developer, currently works in bytecode team, formerly in China Literature New Product Technology Center. GitHub

Session: https://developer.apple.com/videos/play/wwdc2020/10659/

This article is not about how to create IAP channels, how to call StoreKit apis, and how to deal with Apple’s review, but what apple has done in WWDC2020 to address the pain points of previous IAP development and testing. Readers of this article should have some experience in IAP development. From the author’s point of view, evaluate these improvements based on my own experience, such as how valuable they are to individual developers or developers in large companies.

  • The Sandbox environment will finally be able to enjoy the same manual unsubscribe and automatic subscription as the formal environment, and will be able to re-experience first-order offers, refunds, upgrades, and downgrades without creating a new Sandbox test account.
    • Developer Gospel, Apple dad still loves us, this really saves a lot of development and testing costs for automatic renewal.
  • Apple makes a StoreKitTest library for automated testing.
    • The symbolic significance is greater than the practical significance. Under my working experience, I feel that it is very difficult to promote the automation test in China at present. Test development is basically applied to interface testing.
  • It is now possible to build a local sandbox purchase environment (StoreKit Configuration) when testing locally
    • For individual indie developers, small apps with client-side verification orders can save a considerable amount of cost;
    • For large App developers, there is a certain cost of adaptation. Orders from large companies are placed on the server for verification, and full-time staff are responsible for maintaining an SDK. There is still a certain amount of work to be done by external teams for supporting changes (server verification).

Local Sandbox purchase environment (StoreKit Configuration File)

Review previous IAP development experiences

  1. Log in to AppStore Connect and create an APP
  2. Create the corresponding IAP slot, depending on the mood of the Apple server, and roughly 2 hours later you will be able to access the corresponding ProductId item in the sandbox environment
  3. Create a sandbox account
  4. If Apple’s sandbox server gives you face and all goes well, you can start testing. I often encounter sandbox environment login can not go up, and simply can not connect to the sandbox environment, I hope apple sandbox can be more stable…
  5. With the APP versionRaise IAP level, expect Apple to approve dad don’t give2.1 packageor3.1.2Relevant rejected, and inBags have been audited and stalls have been auditedRelease version after. I’ve seen apps approved at both companies but in-app purchases not approved 🙂

Current improvements

You can create a StoreKit Configuration File locally, which allows you to directly control the sandbox environment locally, create new products, including initial offers, automatic renewal control next deduction, unsubscribe control, Ask to Buy control, and so on. The StoreKit Configuration File is basically what AppStore Connect has. (Except there is no non-renewed subscription type)

steps

1. Create a template file and select the newly created empty file



2. To create an item of the desired type, click in the lower left corner+Three options appear.

Each of these three IAP types is described below by the new AppStore Connect, which should suffice. There is currently a lack of non-renewed subscription types. Apple didn’t say why this is the only one missing, but probably didn’t think it was necessary…

3. Creation of consumable projects
  • ProductId is unique when you create it. Even if you delete it, it will no longer be used. Therefore, do not delete it even if you create it wrong. But localStoreKit Configuration FileThere is no such limit. In addition, it is recommended to use semantic creation method. It is recommended not to use pure numbers or randomly generated ids, otherwise the readability is not very good.
  • Apple doesn’t seem to have a country-by-country pricing yet, the input Price unit is us $(although this is really not important at the time of development), just make sure that the AppStore Connect is created correctly. It is ok to create the wrong, you can change, before the interrogation, it is recommended that many people cross check again, because if the approval of the price change is very troublesome… Please let me recommend you to create a new one and try again…There is also an option for Family Sharing in the non-expendable project option, which has been passed over.
4. Creation of auto-renew subscription items
  • You need to create a GroupId, which is the same as in AppStore Connect, because items in the same Group can be upgraded or downgraded. aboutDemotioneing runSo I’m not going to do it here. Basically, there are three levels, 1-2-3, as shown in the diagram below1, can be done by dragging the2Button to adjust, my screenshots are all 1, so the processing logic is a little easier 🙂
  • Types of preferential (Introductory Offer) opening is very full, AppStore Connect what, what is it, dad’s warm feeling the apple. In the picture, I chose an initial offer with a free 7-day trial, which is quite common.
  • Promotional Offers are good, too, though I haven’t used them.
5. Apply the StoreKit file

Switch to in the Edit SchemeOptionsTab, and then inStoreKit ConfigurationSelect the StoreKit file you created.

6. Manage order status locally

You can delete historical orders, delete the first discount, you can refund and other operations. It’s very convenient.

  • Refund operation, after selecting a certain order, directly click the refund button can be realized. Notice that Apple has given a new API to respond to.
  • Ask to Buy, select.storekitAfter the file, options appear in the Editor, which you can turn on. And then after the purchase, the Ask to Buy popup is displayed, and the order status isPending to Approval, you can do it in Xcode, allow it or disallow it. In the figure below, 2 is the Approve button and 3 is the deny button.
  • Other features, including shortening the Time Rate (automatic renewal is comfortable) and allowing interrupted Purchases (Enable Interruted daylight), are available to meet your specific self-test needs.

Local order verification

It should be noted that the verification of orders will be different. Although it uses Apple’s asymmetric encryption, it is a different certificate, so it is needed to verify the orderPKCS7_NOCHAINThis parameter is to be specified. If local authentication is not requiredThe corresponding server logic also responds to changes.Cer files can also be exported. The export method is also in Editor-Save Public Certificate.

Improvements to sandbox environments

Sandbox accounts finally have admin pagesDo you have any idea how I’ve managed without managing pages for years 🙂

Here is a sandbox account we applied for before, which has been created to 300 because we want to test various initial offers:

On iOS14 devices, Settings – App Store – go to the bottom to log in to the sandbox account, click the sandbox account, and then click Manage to enter the admin page.

The administration page provides several functions

  1. Switch purchase items, you can test the same Group within the upgrade or downgrade
  2. Reworking the first offer you enjoyed, you can test the first offer again and again with the same sandbox account instead of opening a new account
  3. Unsubscribe In the past, this was not possible, which greatly facilitated QA and RD verification.

An Interuptted Purchase for setting up sandbox accounts on AppStore Connect

In User & Access, Edit turns on the option.

Some other improvements are expected

  • Sandbox environment hope to be a little more stable, do not appear to wait for a long time as a result of landing failed. This really affects the development experience.
  • At present, some cases can only be verified locally by RD students (they need to operate in Xcode), and there is no way to use the packages made by balers to carry out tests. I hope to open source some toolkits, build a small server locally, specify the IAP of the package to go to the server created locally, anyway, now the.cer certificate can also be exported, for Apple should be very simple things, so QA students can freely verify all cases.

reading

  • Setting up StoreKit Testing in Xcode
  • StoreKitTest
  • Testing at All Stages of Development with Xcode and Sandbox
  • Testing In-App Purchases in Xcode
  • Testing In-App Purchases with Sandbox

Limited welfare

This article is from WWDC20 Inside Reference. I recommend this column here.

The “WWDC Insider reference” series was initiated by the veteran Driver Weekly, Knowledge Collection and SwiftGG technology organizations. We’ve been doing it for a couple of years, and it’s been good. It is mainly for the annual WWDC content, do a selection, and call on a group of front-line Internet iOS developers, combined with their actual development experience, Apple documents and video content to do a second creation.

There are 213 sessions this year. WWDC20 Insider selected 135 of these sessions, and the column has now produced 97 articles. It is on sale now, only 29.9 yuan, very discount.

See article also not enough friends, to subscribe to the WWDC20 inside ~ https://xiaozhuanlan.com/wwdc20 to continue reading

Pay attention to our

We launched LSJCoiding, a weekly newsletter for veteran drivers, which is called a welcome update to each issue.