鍍金池/ 教程/ iOS/ 創(chuàng)建和配置產(chǎn)品
恢復(fù)購(gòu)買記錄
內(nèi)置購(gòu)買
介紹
準(zhǔn)備應(yīng)用程序?qū)彶?/span>
創(chuàng)建和配置產(chǎn)品
獲取產(chǎn)品信息
支付請(qǐng)求
使用訂閱
如何測(cè)試應(yīng)用程序內(nèi)置購(gòu)買
產(chǎn)品交付

創(chuàng)建和配置產(chǎn)品

A product is something you want to sell in your app’s store. You create and configure products in iTunes Connect, and your app interacts with products using the SKProduct and SKProductsRequest classes.

產(chǎn)品是你想要在應(yīng)用商店里出售的東西。 你在 iTunes Connect 里創(chuàng)建和配置產(chǎn)品,然后你的應(yīng)用程序使用 SKProduct 和 SKProctsRequest 類跟產(chǎn)品交互。

Understanding What You Can Sell Using In-App Purchase

一、了解什么產(chǎn)品你可以使用內(nèi)置購(gòu)買出售

You can use In-App Purchase to sell content, app functionality, and services.

你可以使用內(nèi)置購(gòu)買出售內(nèi)容,應(yīng)用功能和服務(wù)。

  • Content. Deliver digital content or assets, such as magazines, photos, and artwork. Content can also be used by the app itself—for example, additional characters and levels in a game, filters in a camera app, and stationery in a word processor.

內(nèi)容。傳遞數(shù)字內(nèi)容或資產(chǎn),比如雜志,相片和藝術(shù)品。 內(nèi)容還可以被應(yīng)用自己使用--比如,游戲中額外的角色和關(guān)卡,一個(gè)照相機(jī)應(yīng)用的濾鏡以及一個(gè)文本處理器的文具(stationery)。

  • App functionality. Unlock behavior and expand features you’ve already delivered. Examples include a free game that offers multiplayer mode as an in-app purchase and a free weather app that lets users make a one-time purchase to remove ads.

應(yīng)用功能。解鎖你已經(jīng)傳遞的行為和擴(kuò)展功能。 比如一個(gè)免費(fèi)游戲中提供一個(gè)多人模式作為一個(gè)內(nèi)置購(gòu)買產(chǎn)品,以及一個(gè)免費(fèi)的天氣應(yīng)用提供一個(gè)內(nèi)置購(gòu)買讓用戶移除廣告。

  • Services. Have users pay for one-time services such as voice transcription and for ongoing services such as access to a collection of data.

服務(wù)。用戶支付一次性服務(wù)比如聲音的轉(zhuǎn)錄,用戶支付長(zhǎng)期服務(wù)比如訪問(wèn)一個(gè)數(shù)據(jù)集。

You can’t use In-App Purchase to sell real-world goods and services or to sell unsuitable content.

你不能用內(nèi)置購(gòu)買出售真實(shí)世界物品和服務(wù)或者出售不恰當(dāng)?shù)膬?nèi)容。

  • Real-world goods and services. You must deliver a digital good or service within your app when using In-App Purchase. Use a different payment mechanism to let your users buy real-world goods and services in your app, such as a credit card or payment service.

真實(shí)世界物品和服務(wù)。當(dāng)你使用內(nèi)置購(gòu)買時(shí),你必須在應(yīng)用程序里傳遞一個(gè)數(shù)字物品或服務(wù)。 使用一個(gè)不同的支付機(jī)制讓你的用戶在應(yīng)用中購(gòu)買真實(shí)世界物品和服務(wù),比如信用卡或支付服務(wù)。

  • Unsuitable content. Don’t use In-App Purchase to sell content that the isn’t allowed by the App Review Guidelines—for example, pornography, hate speech, or defamation.

不恰當(dāng)?shù)膬?nèi)容。 不要使用內(nèi)置購(gòu)買來(lái)出售應(yīng)用程序?qū)徍藰?biāo)準(zhǔn)禁止的內(nèi)容---比如,色情,仇恨言論或者誹謗。

For detailed information about what you can offer using In-App Purchase, see your license agreement and the App Review Guidelines. Reviewing the guidelines carefully before you start coding helps you avoid delays and rejection during the review process. If the guidelines don’t address your case in sufficient detail, you can ask the App Review team specific questions using the online contact form.

更多關(guān)于使用內(nèi)置購(gòu)買可以提供的內(nèi)容,請(qǐng)看 your license agreement and the App Review Guidelines. 在開(kāi)始編碼之前仔細(xì)閱讀審核指南可以幫你免除審核過(guò)程中德延遲和拒絕。 如果指南不涉及你需要的細(xì)節(jié),你可以使用 online contact form 詢問(wèn)應(yīng)用審核團(tuán)隊(duì)特定的問(wèn)題。

After you know what products you want to sell in your app and determine that In-App Purchase is the appropriate way to sell those products, you need to create the products in iTunes Connect.

當(dāng)你知道你想要在應(yīng)用程序中出售什么并確定內(nèi)置購(gòu)買時(shí)出售那些產(chǎn)品的恰當(dāng)方式后,你需要在 iTunes Connect 中創(chuàng)建產(chǎn)品。

Creating Products in iTunes Connect

二、在 iTunes Connect 中創(chuàng)建產(chǎn)品

Before you start coding, you need to configure products in iTunes Connect for your app to interact with. As you develop your app, you can add and remove products and refine or reconfigure your existing products.

在開(kāi)始編碼之前,你需要在 iTunes Connect 中為你的應(yīng)用程序配置與之交互的產(chǎn)品。 當(dāng)你開(kāi)發(fā)應(yīng)用程序時(shí),你可以添加和刪除產(chǎn)品以及改進(jìn)或重新配置你現(xiàn)有的產(chǎn)品。

Every product is associated with a specific app. Products created for use by one app are not available in other apps. Companion apps on a different platform are different apps—the products of the Mac app are not available in the iOS app and vice versa.

每個(gè)產(chǎn)品都跟一個(gè)特定的應(yīng)用程序相關(guān)聯(lián)。 一個(gè)產(chǎn)品只對(duì)應(yīng)一個(gè)應(yīng)用程序,它不能被別的應(yīng)用程序使用。在不同平臺(tái)上的兄弟應(yīng)用是不同的應(yīng)用程序--Mac應(yīng)用程序的產(chǎn)品在 iOS 等中是無(wú)法工作的。

Products are reviewed when you submit your app as part of the app review process. Before users can buy a product, it must be approved by the reviewer and you must mark it as “cleared for sale” in iTunes Connect.

當(dāng)你遞交應(yīng)用時(shí),產(chǎn)品會(huì)作為應(yīng)用審核的一部分進(jìn)行審核。 在用戶可以購(gòu)買一個(gè)產(chǎn)品之前,它必須通過(guò)審核并在 iTunes Connect 中標(biāo)記為“cleared for sale”。

For step-be-step information about working with products in iTunes Connect, In-App Purchase Configuration Guide for iTunes Connect.

關(guān)于跟 iTunes Connect 中產(chǎn)品合作的更多信息,請(qǐng)看In-App Purchase Configuration Guide for iTunes Connect.

Product Types

三、產(chǎn)品類型

Product types let you use In-App Purchase in a range of apps by providing several different product behaviors. In iTunes Connect, you select one of the following product types:

產(chǎn)品類型通過(guò)提供一些不同的產(chǎn)品行為,讓你在特定的應(yīng)用程序范圍內(nèi)使用內(nèi)置購(gòu)買。 在 iTunes Connect 中,你可以選擇以下產(chǎn)品類型:

  • Consumable products. Items that get used up over the course of running your app. Examples include minutes for a Voice over IP app and one-time services such as voice transcription.

耗材產(chǎn)品。應(yīng)用程序運(yùn)行過(guò)程中會(huì)耗盡的產(chǎn)品。 比如,包括一個(gè)幾分鐘的 IP 語(yǔ)音應(yīng)用和一次性服務(wù)比如錄音。

  • Non-consumable products. Items that remain available to the user indefinitely on all of the user’s devices. They’re made available to all of the user’s devices. Examples include content, such as books and game levels, and additional app functionality.

非耗材產(chǎn)品。 所有用戶設(shè)備上都能一直保持可用狀態(tài)的產(chǎn)品。它們對(duì)于用戶的所有設(shè)備都一樣可用。例子包括內(nèi)容,比如書(shū)和游戲關(guān)卡,以及更多地應(yīng)用功能。

  • Auto-renewable subscriptions. Episodic content. Like non-consumable products, auto-renewable subscriptions remain available to the user indefinitely on all of the user’s devices. Unlike non-consumable products, auto-renewable subscriptions have an expiration date. You deliver new content regularly, and users get access to content published during the time period their subscription is active. When an auto-renewable subscription is about to expire, the system automatically renews it on the user’s behalf.

    自動(dòng)再生訂閱。 章節(jié)內(nèi)容, 就像非耗材產(chǎn)品,自動(dòng)再生訂閱在用戶設(shè)備上也是永久可用。不同于非耗材產(chǎn)品的是,自動(dòng)再生訂閱它有過(guò)期時(shí)間。 你定期傳遞新的內(nèi)容,用戶在它們的訂閱有效期間可以訪問(wèn)出版的內(nèi)容。當(dāng)一個(gè)自動(dòng)再生訂閱就要到期時(shí),系統(tǒng)自動(dòng)以用戶的名義續(xù)訂它。

  • Non-renewable subscriptions. Subscriptions that don’t involve delivering episodic content. Examples include access to a database of historic photos or a collection of flight maps. It’s your app’s responsibility to make the subscription available on all of the user’s devices and to let users restore the purchase. This product type is often used when your users already have an account on your server that you can use to identify them when restoring content. Expiration and the duration of the subscription are also left to your app (or your server) to implement and enforce.

非再生訂閱。 不涉及傳遞章節(jié)內(nèi)容的訂閱。例子包括訪問(wèn)一個(gè)歷史照片的數(shù)據(jù)庫(kù)或者一個(gè)航班表。 你有責(zé)任讓訂閱在所有用戶的設(shè)備都可用,并且讓用戶恢復(fù)購(gòu)買。 該產(chǎn)品類型通常在用戶已經(jīng)在你的服務(wù)器上有一個(gè)賬號(hào),你可以在用戶恢復(fù)內(nèi)容時(shí)用它認(rèn)證他們。 到期和認(rèn)購(gòu)時(shí)間也保留在你的應(yīng)用(或服務(wù)器)中以供實(shí)現(xiàn)和執(zhí)行。

  • Free subscriptions. A way to put free subscription content in Newsstand. After a user signs up for a free subscription, the content is available on all devices associated with the user’s Apple ID. Free subscriptions don’t expire and can be offered only in Newsstand-enabled apps.

免費(fèi)訂閱。 一種在報(bào)刊雜志中投放免費(fèi)訂閱的方法。 當(dāng)用戶注冊(cè)了一個(gè)免費(fèi)訂閱后,訂閱內(nèi)容在用戶的 Apple ID 相關(guān)的所有設(shè)備中都是可用的。 免費(fèi)訂閱不會(huì)到期,只能在開(kāi)啟報(bào)刊雜志的應(yīng)用中提供。

Differences Between Product Types

四、產(chǎn)品類型之間的區(qū)別 Each product type is designed for a particular use. The behavior of different product types varies in certain ways, as summarized in Table 1-1 and Table 1-2.

每個(gè)產(chǎn)品類型被設(shè)計(jì)用于特定用途。不同產(chǎn)品類型的行為在特定方式中會(huì)發(fā)生變化,如表格1-1,1-2中所述。

http://wiki.jikexueyuan.com/project/in-app-purchase/images/3.png" alt="" />

Products that expire or get used up—consumable products, auto-renewable subscriptions, and non-renewing subscriptions—can be purchased multiple times to get the consumable item again or extend the subscription. Non-consumable products and free subscriptions unlock content that remains available to the user indefinitely, so these can only be purchased once.

到期或耗盡產(chǎn)品--耗材產(chǎn)品,自動(dòng)再生訂閱以及非再生訂閱--可以多次購(gòu)買以再次獲取耗材產(chǎn)品或者續(xù)訂。 非耗材產(chǎn)品和免費(fèi)訂閱會(huì)永久的讓產(chǎn)品保持有用,所以它們只需購(gòu)買一次。

Consumable products and non-renewing subscriptions appear in the receipt after being purchased but are removed the next time the receipt is updated, as discussed in more detail in “Persisting Using the App Receipt.” All other types of products have an entry in the receipt that isn’t removed.

耗材產(chǎn)品和非再生訂閱在購(gòu)買了之后在 receipt 那出現(xiàn),但是它們將在 receipt 下次更新時(shí)被刪除,更多詳情請(qǐng)看 “Persisting Using the App Receipt.” 剩余產(chǎn)品類型在 receipt 那都有一個(gè)條目(entry)并且不會(huì)被刪除。

Consumable products, by their nature, aren’t synced or restored. Users understand that, for example, buying ten more bubbles on their iPhone doesn’t also give them ten more bubbles on their iPad. All other types of products are made available across all of the user’s devices. They’re also restored so users can continue to access their purchased content even after buying a new device. Store Kit handles the syncing and restoring process for auto-renewable and free subscriptions and for non-consumable products.

耗材產(chǎn)品,通常不同步或不能恢復(fù)。就是說(shuō),在 iPhone 上購(gòu)買了10個(gè)氣球,并不表示 iPad 也得給它們10個(gè)氣球。所有其它產(chǎn)品類型都可以跨平臺(tái)使用。 它們還可以恢復(fù),所以用戶可以繼續(xù)訪問(wèn)它們購(gòu)買的內(nèi)容,即使它換了一個(gè)新設(shè)備。 商店 Kit 處理同步,為自動(dòng)再生,免費(fèi)訂閱和非耗材產(chǎn)品處理恢復(fù)。

Non-renewing subscriptions differ from auto-renewable subscriptions in a few key ways. These differences give your app the flexibility to implement the correct behavior for your needs, as follows:

非再生訂閱與自動(dòng)再生訂閱在一些關(guān)鍵方法上有所不同。這些不同讓你的應(yīng)用可以靈活地根據(jù)需要實(shí)現(xiàn)正確的行為,如下:

  • Your app is responsible for calculating the time period that the subscription is active and determining what content needs to be made available to the user.

應(yīng)用程序負(fù)責(zé)計(jì)算訂閱有效的時(shí)間并且決定什么內(nèi)容需要開(kāi)放給用戶。

  • Your app is responsible for detecting that a subscription is approaching its expiration date and prompting the user to renew the subscription by purchasing the product again.

應(yīng)用程序負(fù)責(zé)偵測(cè)訂閱即將到期,提醒用戶再次購(gòu)買產(chǎn)品來(lái)更新訂閱。

  • Your app is responsible for making subscriptions available across all the user’s devices after they’re purchased and for letting users restore past purchases. For example, most subscriptions are provided by a server; your server would need some mechanism to identify users and associate subscription purchases with the user who purchased them.

應(yīng)用程序負(fù)責(zé)用戶購(gòu)買成功后讓訂閱能夠跨平臺(tái)使用,并且讓用戶恢復(fù)過(guò)去的購(gòu)買記錄。 比如,大多數(shù)訂閱都有一個(gè)服務(wù)器提供;你得服務(wù)器將需要一些機(jī)制來(lái)認(rèn)證用戶并把購(gòu)買的訂閱跟用戶關(guān)聯(lián)到一起。