Introduction | Designing Your App’s Store | Displaying Your App’s Store UI | Requesting Payment
Delivering Products | Providing Purchased Content | Working with Subscriptions | Preparing for App Review

본 페이지는 iOS In-App Purchase Programming Guide 문서의 Working with Subscriptions 부분을 번역해 놓은 페이지 입니다. 발 번역이라 이상한 부분이 있을 수 있습니다. 발견즉시 댓글을 달아 주세요.




Working with Subscriptions
구독에 대한 작업

Apps that use subscriptions have some additional behaviors and considerations. Subscriptions incorporate an element of time, and your app needs to have the appropriate logic to determine whether the subscription is currently active and what time periods the subscription was active in the past. Your app also needs to react to new and renewed subscriptions, and properly handle expired subscriptions. Figure 6-1 show an example subscription timeline, including some of the complexities your app needs to handle.

구독을 사용하는 응용 프로그램은 몇 가지 추가 행동과 고려 사항이 있습니다. 구독은 시간의 요소를 통합하고 응용 프로그램은 서브 스크립 션은 현재 활성화되어 있고 어떤 시간 기간 가입이 과거에 활성 여부를 확인하는 적절한 논리가 있어야합니다. 당신의 애플 리케이션은 새로운 갱신 구독에 반응하고, 제대로 만료 된 구독을 처리해야합니다. 그림 6-1는 응용 프로그램이 처리해야하는 복잡성의 일부를 포함하여, 예를 구독 타임 라인을 보여줍니다.

Figure 6-1  Example subscription timeline


Calculating a Subscription’s Active Period
구독의 활동 기간을 계산

Your app needs to determine what content the user has access to based on the period of time that the subscription was active. Consider, for example, a magazine that publishes a new issue on the first day of each month. On February 7, the user buys a 3 month subscription When the user buys the subscription, the February issue is delivered immediately. In addition, the user gets access to all of the issues that are published between the subscription’s start and end dates. Finally, on April 7, the subscription expires. There are a total of three issues available to the user—February, March, and April—as shown in Table 6-1.

귀하의 응용 프로그램은 사용자가 가입이 활성화 된 시간의 기간을 기준에 액세스 할 수있는 어떤 내용을 확인해야합니다. 예를 들어, 각 월의 첫 번째 날에 새로운 이슈를 게시 잡지를 고려하십시오.사용자가 구독을 구입하면 년 2 월 7 일, 사용자가 3 개월 가입을 구입, 2 월호는 즉시 전달됩니다. 또한, 사용자는 구독의 시작 및 끝 날짜 사이에 게시되는 모든 문제에 대한 액세스 권한을 얻을 수 있습니다. 마지막으로, 4 월 7 일에 가입이 만료됩니다.에 사용할 세 가지 문제의 전체 사용자 2 월, 3 월, 4 월 - 표 6-1에서와 같이.가있다

Table 6-1  Timeline of a sample subscription

Magazine issue

User has access to content?

January 1

No, subscription has not started

February 1

Yes, delivered when the user subscribed

March 1

Yes, delivered at the time of its publication

April 1

Yes, delivered at the time of its publication

May 1

No, subscription expired on April 7

To implement this logic in your app, keep a record of the date that each piece of content is published. The user is has access to all content published between the start and end dates, as well as the content that was initially unlocked when the subscription was purchased.

귀하의 응용 프로그램에이 논리를 구현하는 각 콘텐츠가 게시 한 날짜의 기록을 유지.사용자는 시작 날짜와 종료 날짜뿐만 아니라 서브 스크립 션을 구입하면 처음에 잠금이 해제 된 내용 사이에 출판 된 모든 콘텐츠에 액세스 할 수 있습니다.

Expiration and Renewal
만료 및 갱신

The renewal process begins with a “preflight” check, starting ten days before the expiration date. During those ten days, the store checks for any issues that might delay or prevent the subscription from being automatically renewed—for example, if the customer no longer has an active payment method, if the product’s price increased since the user bought the subscription, or if the product is no longer available. The store notifies users of any issue so that they can resolve it before the subscription needs to renew, ensuring their subscription is not interrupted.

갱신 프로세스는 만료일 10 일전부터 "프리 플라이트"체크로 시작합니다. 그 십일 동안 저장소 지연이나되는 가입을 방지 수있는 문제에 대한 검사 자동 갱신 - 예를 들어, 고객은 더 이상 사용자가 구독을 구입 한 이후 제품의 가격이 상승하면, 활성 지불 방법이없는 경우, 또는제품은 더 이상 사용할 수없는 경우. 구독이 자신의 가입이 중단되지 않습니다 보장, 갱신 할 필요가 전에 그것을 해결할 수 있도록 상점은 모든 문제를 사용자에게 알려줍니다.

During the 24 hour period before the subscription expires, the store starts trying to automatically renew it. The store makes several attempts to automatically renew the subscription, but eventually stops if there are too many failed attempts.

구독이 만료되기 전에 24 시간 기간 동안 저장소가 자동으로 갱신을 시도 시작합니다.저장소가 자동으로 구독을 갱신하는 여러 시도를 만들지 만, 너무 많은 실패한 시도가있을 경우 결국 정지합니다.

The store renews the subscription slightly it expires, to ensure that there there is no lapse in the subscription. However, lapses are still possible. For example, if the user’s payment information was no longer valid, then the first renewal attempt would fail. If the user didn’t update this information until after the subscription expired, there would be a short lapse in the subscription between the expiration date and the date that a subsequent automatic renewal succeeded. The user can also disable automatic renewal and intentionally let the subscription expire, then renew it at a later date, creating a longer lapse in the subscription. Make sure your app’s subscription logic can handle lapses of various durations correctly.

상점 구독에는 경과가 없다는 것을 보장하기 구독 약간 만료를 갱신합니다. 그러나 경과는 여전히 가능합니다.사용자의 결제 정보가 더 이상 유효 없었던 경우는 예를 들어, 첫 번째 갱신 시도가 실패합니다. 사용자가 구독 만료 때까지이 정보를 업데이트하지 않은 경우 만료 날짜 및 이후 자동 갱신이 성공 된 날짜 사이의 구독에서 짧은 경과있을 것입니다.사용자는 또한 자동 갱신을 사용하지 않도록 의도적으로 구독에 이상 경과를 만들어 나중에를 갱신 한 후, 구독 만료하도록 할 수 있습니다. 앱의 가입 로직이 올바르게 다양한 기간의 만료를 처리 할 수 ​​있는지 확인합니다.

After a subscription is successfully renewed, Store Kit adds a transaction for the renewal to the transaction queue. Your app checks the transaction queue on launch, and handles the renewal the same way as any other transaction. Note that if your app is already running when the subscription renews the transaction observer isnot called; your app finds out about the renewal the next time it is launched.

구독이 성공적으로 갱신 된 후, 스토어 키트는 트랜잭션 큐에 갱신 트랜잭션을 추가합니다. 귀하의 응용 프로그램은 실행의 트랜잭션 대기열을 확인하고 갱신 다른 어떤 거래와 같은 방식으로 처리합니다. 앱이 갱신이 시작됩니다 다음에 대해 발견, 구독라는 트랜잭션 옵저버 isnot 일을 갱신 할 때 응용 프로그램이 이미 실행중인 경우 있습니다.

Cancellation
해제

A subscription is paid for in full when it is purchased and can be refunded only by contacting Apple customer service. For example, if the user accidentally bought the wrong product, customer support can cancel the subscription and issue a refund. It is not possible for customers to change their mind in the middle of a subscription period and decide they don’t want to pay for the rest of the subscription.

그것은 단지 애플의 고객 서비스에 연락하여 구입 및 환불 될 수있을 때 구독이 전액 지급된다.사용자가 실수로 잘못된 제품을 구입하는 경우 예를 들어, 고객 지원은 등록을 취소하고 환불을 발행 할 수 있습니다. 고객이 가입 기간의 중간에 마음을 변경하고 결정들이 가입의 나머지를 지불하고 싶지 않아하는 것은 불가능합니다.

To check whether a purchase has been canceled, look for the cancellation date in the receipt. If the field is missing or has no date, the purchase is not canceled. If the field has a date in it, regardless of the subscription’s expiration date, the purchase has been canceled—treat a canceled receipt the same as if no purchase had ever been made.

구매가 취소되었는지 여부를 확인하려면, 영수증 캔슬 날짜를 찾으십시오.필드가 없거나 더 날짜가되지 않은 경우, 구입이 취소되지 않습니다.필드에 관계없이 등록의 유효 기한, 그것에있는 일이 있다면, 구입은 구입도 이루어지지했던 동일한 경우로 취소 접수를 취소 처리되었습니다.

Depending on the type of product, you may be able to check only the currently active subscription, or you may need to check all past subscriptions. For example, a magazine app would need to check all past subscriptions to determine which issues the user had access to.

제품의 유형에 따라, 당신은 현재 활성 구독을 확인하거나, 당신은 모든 과거의 구독을 확인해야 할 수 있습니다. 예를 들어, 잡지 앱은 사용자가 액세스었던 문제를 결정하기 위해 모든 과거 구독을 확인해야합니다.

Cross-Platform Considerations
크로스 플랫폼 고려 사항

Product identifiers are tied to a specific platform. If you want to let users who have a subscription in an iOS app access the content from an OS X app (or vice versa), that is up to your apps. You will need to have some system for identifying users and keeping track of what content they have subscribed to, similar to what you would implement for an app that uses non-renewable subscriptions.

제품 식별자는 특정 플랫폼에 묶여있다. 당신은 IOS 애플 리케이션에 가입 한 사용자가 귀하의 응용 프로그램입니다 OS X 응용 프로그램 (또는 그 반대)의 내용에 액세스 할 수 있도록하려는 경우. 당신은 재생 불가능한 구독을 사용하는 응용 프로그램에 대해 구현하는 것과 유사한 사용자를 식별하고 그들이에 가입 한 어떤 내용의 트랙을 유지하는 일부 시스템을 가지고해야합니다.

The Test Environment
테스트 환경

For the sake of testing, there are some differences in behavior between auto-renewable subscriptions in the production environment and in the test environment.
테스트를 위해서, 생산 환경과 테스트 환경에서 자동 갱신 구독과 행동에 약간의 차이가 있습니다.

Renewal happens at an accelerated rate, and auto-renewable subscriptions renew a maximum of six times per day. This lets you test how your app handles subscription renewal and how it handles a renewal after a lapse and how it handles a subscription history that includes gaps.
갱신은 빠른 속도로 발생하고, 자동 갱신 구독은 매일 6 회에 최대를 갱신. 이 앱이 등록 갱신 방법이 경과 한 후에는 그것이 어떻게 간격을 포함 구독 내역을 처리하는 갱신 처리를 처리하는 방법을 테스트 할 수 있습니다.

Because of the accelerated expiration and renewal rate, the subscription can expire before the system starts trying to renew the subscription, leaving a small lapse in the subscription period. Such lapses are also possible in production for a variety of reasons—make sure your app handles them correctly.

시스템은 가입 기간에있는 작은 경과를 떠나, 구독을 갱신하려고 시작하기 전에 때문에 가속 만료 및 갱신 속도, 구독 만료 될 수 있습니다. 이러한 경과는 응용 프로그램이 올바르게 처리해야 이유 메이크의 다양한 생산도 가능합니다.

Posted by 창업자닉군
,

Introduction | Designing Your App’s Store | Displaying Your App’s Store UI | Requesting Payment
Delivering Products | Providing Purchased Content | Working with Subscriptions | Preparing for App Review

본 페이지는 iOS In-App Purchase Programming Guide 문서의 Providing Purchased Content 부분을 번역해 놓은 페이지 입니다. 발 번역이라 이상한 부분이 있을 수 있습니다. 발견즉시 댓글을 달아 주세요.




Providing Purchased Content
구입 한 콘텐츠를 제공

There are several approaches for delivering content: You can include content in your app bundle, download content from your own server, or download content from Apple’s servers. There is a design tradeoff between the competing desires to make content available to the user as quickly as possible after it is purchased, and the desire to keep the initial download size of the app small. If you include too little in your app bundle, the user must wait for even small purchases to download. If you include too much in your app bundle, the initial download of the app takes much longer, the space is wasted for users who don’t purchase the corresponding products, and, if the app becomes larger than 50 megabytes, users won’t be able to download it over a cellular network.

내용을 전달하기위한 몇 가지 방법이 있습니다 : 당신은 당신의 애플 리케이션 번들의 내용을 포함 할 수 있습니다, ​​자신의 서버에서 콘텐츠를 다운로드하거나 애플의 서버에서 콘텐츠를 다운로드 할 수 있습니다. 은 구입 후 가능한 빨리 사용자가 콘텐츠를 사용할 수 있도록 경쟁 욕망 사이의 디자인 트레이드 오프, 소규모 응용 프로그램의 초기 다운로드 크기를 유지하는 욕망이 있습니다. 당신은 당신의 애플 리케이션 번들 너무 적게 포함하는 경우도 작은 구매를 다운로드하려면, 사용자는 기다려야합니다. 당신은 당신의 애플 리케이션 번들에 너무 많이 포함하는 경우, 응용 프로그램의 초기 다운로드 시간이 더 오래 걸립니다 공간이 해당 제품을 구매하지 않는 사용자를 위해 낭비되고, 응용 프로그램이 50메가바이트보다 큰 될 경우, 사용자는하지 않습니다셀룰러 네트워크를 통해 다운로드 할 수 있습니다.

Embed small files (up to a few megabytes) in your app, especially if you expect most users to buy that product. This lets you make the purchased content available immediately. To add or update content in your app bundle, you have to submit an updated version of your app.

당신은 대부분의 사용자가 해당 제품을 구입하기 위해 기대 특히, 당신의 애플 리케이션에 작은 파일 (최대 몇 메가 바이트에) 포함. 이것은 당신이 바로 구입 한 콘텐츠를 사용할 수 있도록 할 수 있습니다. 귀하의 응용 프로그램 번들에 컨텐츠를 추가하거나 업데이트하려면, 당신은 귀하의 응용 프로그램의 업데이트 된 버전을 제출해야합니다.

Host larger files on a server and download them when needed. You can add or update hosted content without needing to submit an updated version of your app (assuming your app uses a dynamic list of products). You can use hosted content associated with a free non-consumable purchase to deliver additional content while keeping your app’s initial download small. For example, a game can include the first level it its app bundle and let users download the rest of the levels for free from Apple’s servers.

서버에 큰 파일을 호스팅하고 필요할 때 다운로드 할 수 있습니다. 당신은 응용 프로그램의 업데이트 된 버전 (응용 제품의 동적 목록을 사용하는 가정)을 제출하지 않고 호스팅 내용을 추가하거나 업데이트 할 수 있습니다. 당신은 응용 프로그램의 초기 다운로드를 작게 유지하면서 추가 콘텐츠를 제공하는 무료 비 소모품의 구입에 관련된 호스팅 콘텐츠를 사용할 수 있습니다. 예를 들어, 게임은 첫 번째 수준의 그것에게 그것의 응용 프로그램 번들을 포함하고 사용자가 애플의 서버에서 무료로 수준의 나머지 부분을 다운로드하도록 할 수 있습니다.

When you host content on Apple’s servers you don’t need to worry about the server infrastructure. It is built on the same infrastructure that supports other large-scale operations, such as the iTunes Store, so your app can depend on it to be robust and scalable. Hosted content automatically downloads in the background even if your app isn’t running.

당신이 애플의 서버에서 콘텐츠를 호스팅 할 때 서버 인프라에 대해 걱정할 필요가 없습니다. 이 같은 아이튠즈 스토어와 같은 다른 대규모 작업을 지원하는 동일한 인프라를 구축하므로 응용 프로그램은 강력하고 확장 할에 의존 할 수 있습니다. 앱이 실행되지 않은 경우에도 콘텐츠를 자동으로 호스팅은 백그라운드에서 다운로드합니다.

When restoring transactions, let the user control what content gets downloaded, as described in Restoring Transactions.

트랜잭션을 복원 할 때, 트랜잭션 복원에 설명 된대로 어떤 내용이 다운로드되는 사용자 정의 컨트롤을 할 수 있습니다.

Unlocking Local Content
로컬 콘텐츠를 잠금 해제

To unlock local content after the user purchases it, load it using the NSBundle class, just as you load other resources from your app bundle.

사용자가 구입 한 후 로컬 콘텐츠의 잠금을 해제하려면, 당신은 당신의 애플 리케이션 번들에서 다른 리소스를로드하는 것처럼 NSBundle 클래스를 사용하여 그것을로드합니다.

NSURL * url = [[NSBundle mainBundle] URLForResource:@"rocket"
                                      withExtension:@"plist"];
[self loadCarAtURL:url];

Downloading Hosted Content from Apple’s Server
애플의 서버에서 호스팅 콘텐츠를 다운로드

When the user purchases a product that has associated hosted content, the transaction passed to your transaction queue observer also includes an instance ofSKDownload which lets you download the content.

사용자가 콘텐츠를 호스팅 관련있는 제품을 구입하는 경우, 트랜잭션 큐 관찰자에게 전달 된 트랜잭션은 또한 콘텐츠를 다운로드 할 수 있습니다 인스턴스 ofSKDownload가 포함되어 있습니다.

To download the hosted content, add the download objects from the transaction’s downloads property to the transaction queue by calling the startDownloads:method of SKPaymentQueue. If the value of the downloads property is nil, there is no hosted content for that transaction. Unlike downloading apps, downloading hosted content does not automatically require a Wifi connection for content larger than a certain size. Avoid using cellular networks to download large files without an explicit action from user.

SKPaymentQueue의 방법 : 호스팅 콘텐츠를 다운로드하려면 startDownloads를 호출하여 트랜잭션의 다운로드 속성에서 트랜잭션 큐에 다운로드 개체를 추가합니다.다운로드 속성의 값이 nil이 경우 해당 거래에 대한 호스팅 내용이 없습니다. , 응용 프로그램을 다운로드 호스팅 콘텐츠를 다운로드 달리 자동으로 특정 크기보다 큰 콘텐츠에 대한 WiFi 연결이 필요하지 않습니다. 사용자의 명시 적 조치없이 대용량 파일을 다운로드하는 셀룰러 네트워크를 사용하지 마십시오.

Implement the paymentQueue:updatedDownloads: method on the transaction queue observer to respond to changes in a download’s state—for example, by updating progress in your UI or by notifying the user of a failed download.

변화에 대응하기 위해 트랜잭션 큐 관찰자에 방법 다운로드의 상태 예를 들어, 귀하의 UI에서 진행 상황을 업데이트하거나 실패한 다운로드의 사용자에게 알리지 기준 : updatedDownloads : paymentQueue를 구현합니다.

Update your user interface while the content is downloading using the values of the progress and timeRemaining properties. You can use the pauseDownloads:,resumeDownloads:, and cancelDownloads: methods of SKPaymentQueue from your UI to let the user control in-progress downloads. Use the downloadStateproperty to determine whether the download has completed. Don’t use the progress or time remaining, these properties wouldn’t let your app accurately tell the difference between downloads that are almost finished and downloads that are completely finished.

내용이 진보와 timeRemaining 속성의 값을 사용하여 다운로드하는 동안 사용자 인터페이스를 업데이트합니다.사용자 정의 컨트롤에서 진행중인 다운로드를하도록 귀하의 UI에서 SKPaymentQueue의 방법 : resumeDownloads : 그리고 cancelDownloads 당신은 pauseDownloads을 사용할 수 있습니다.다운로드가 완료되었는지 여부를 확인하기 위해 downloadStateproperty를 사용합니다. 나머지 진행 또는 시간을 사용하지 마십시오, 이러한 속성은 응용 프로그램이 정확하게 거의 완료 다운로드 완전히 완료 다운로드의 차이를 알려주지 않을 것입니다.

After the download finishes, use its contentURL property to locate the content.
다운로드가 완료된 후, 내용을 찾을 수는 contentURL 속성을 사용합니다.

Downloading Content from Your Own Server
자신의 서버에서 콘텐츠를 다운로드

As with all other interactions between your app and your server, the details and mechanics of this process are up to you. The communication consists of, at minimum, the following steps:

귀하의 응용 프로그램과 서버 사이의 모든 상호 작용과 마찬가지로,이 프로세스의 세부 사항 및 역학 당신에게 달려 있습니다.통신은 최소한 다음 단계에서 구성

  1. Your app sends the receipt to your server and requests the content.
    당신의 앱은 영수증을 서버에 보내고 컨텐츠를 요청합니다.

  2. Your server validates the receipt to establish that the content has been purchased, as described in Receipt Validation Programming Guide.
    서버는 수신 유효성 검사 프로그래밍 가이드에 설명 된대로 콘텐츠가 구입 한 것을 입증하는 영수증을 확인합니다.

  3. Assuming the receipt is valid, your server responds to your app with the content.
    영수증을 가정하는 것은 유효하다, 서버가 콘텐츠를 귀하의 응용 프로그램에 응답합니다.

Consider the security implications of how you host your content and of how your app communicates with your server. For more information, see Security Overview.

당신의 콘텐츠를 호스팅하는 방법과 응용 프로그램이 서버와 통신하는 방법의 보안에 미치는 영향을 고려하십시오. 자세한 내용은 보안 개요를 참조하십시오.

Locating and Managing Downloaded Content
다운로드 된 콘텐츠를 찾기 및 관리

In iOS, your app can manage hosted content after the files are downloaded. The files are saved for you by the Store Kit framework in the Caches directory with the backup flag unset. In most cases, this is the correct behavior—because downloaded content can be re-downloaded, it can be deleted if the user becomes low on disk space (and later restored when disk space becomes available), and it should not be included in the user’s backups. If your app’s downloaded content should not be purgeable, move it to another location. If it should be included in the user’s backup, set the backup flag.

파일을 다운로드 한 후 IOS, 당신의 응용 프로그램은 호스팅 콘텐츠를 관리 할 수 ​​있습니다.파일은 백업 플래그 해제와 캐시 디렉토리에 저장 키트 프레임 워크가 당신을 위해 저장됩니다. 대부분의 경우,이 - 행동 때문에 올바른 다운로드 된 콘텐츠를 다시 다운로드 할 수있는 사용자의 디스크 여유 공간 (디스크 공간을 사용할 수있게되면 나중에 복원)에 낮은 경우, 그것은 삭제 될 수 있으며, 그것은에 포함되어서는 안 사용자의 백업. 앱의 다운로드 된 콘텐츠가 불려 나가지하지 않아야하는 경우, 다른 위치로 이동합니다. 그것은 사용자의 백업에 포함해야하는 경우, 백업 플래그를 설정합니다.

In OS X, hosted content is saved and managed by the system; your app can’t move or delete the files directly. To locate the file after downloading the content, use the contentURL property of the download object. To locate the file on subsequent launches, use the contentURLForProductID: class method of SKDownload. To delete a file, use the deleteContentForProductID: class method. For information about reading the product identifiers from your app’s receipt, see Receipt Validation Programming Guide.

OS X에서 호스팅되는 콘텐츠는 시스템에 의해 저장 및 관리하고, 당신의 응용 프로그램은 파일을 직접 이동하거나 삭제할 수 없습니다.콘텐츠를 다운로드 한 후 파일을 찾으려면, 다운로드 개체의 contentURL 속성을 사용합니다. 후속 실행에있는 파일을 찾으려면 contentURLForProductID를 사용 SKDownload의 수업 방식입니다.파일을 삭제하려면, deleteContentForProductID을 사용하여 클래스의 메서드를. 앱의 영수증에서 제품 ID를 읽기에 대한 자세한 내용은 영수증 유효성 검사 프로그래밍 가이드를 참조하십시오.

Posted by 창업자닉군
,

Introduction | Designing Your App’s Store | Displaying Your App’s Store UI | Requesting Payment
Delivering Products | Providing Purchased Content | Working with Subscriptions | Preparing for App Review

본 페이지는 iOS In-App Purchase Programming Guide 문서의 Delivering Products 부분을 번역해 놓은 페이지 입니다. 발 번역이라 이상한 부분이 있을 수 있습니다. 발견즉시 댓글을 달아 주세요.




Delivering Products
제공하는 제품

In the last part of the purchase process, after the App Store has processed the payment request, your app stores information about the purchase for future launches, downloads the purchased content, and marks the transaction as finished, as shown in Figure 4-1.

구매 프로세스의 마지막 부분에서는 앱 스토어 후 지불 요청, 향후 출시, 구입 한 콘텐츠 다운로드의 구입에 대한 귀하의 응용 프로그램 정보를 저장, 처리 및 마무리 트랜잭션을 표시, 그림 4-1에서 보여 주었다.

Figure 4-1  Stages of the purchase process—delivering products


Waiting for the Store to Process Transactions
공정 거래에 스토어 대기

Implement the paymentQueue:updatedTransactions: method on your transaction queue observer. Store Kit calls this method when the status of a transaction changes—for example, when a payment request has been processed. The transaction status tells you what action your app needs to perform, as shown in Table 4-1and Listing 4-1.

updatedTransactions : 트랜잭션 큐 관찰자의 방법 paymentQueue를 구현합니다. 트랜잭션의 상태가 변경 - 예를 들어, 때 지불 요청이 처리 된 경우 스토어 키트는이 메서드를 호출합니다.트랜잭션 상태는 4-1과 목록 4-1 표에서와 같이 응용이 수행해야 할 작업을 알려줍니다.

Table 4-1  Transaction statuses and corresponding actions

Status

Meaning

Action to take in your app

SKPaymentTransactionStatePurchasing

Transaction still in progress

Update your UI to reflect the status, and wait to be called again.

상태를 반영하기 위해 UI를 업데이트하고 다시 호출 할 때까지 기다립니다.

SKPaymentTransactionStateFailed

Transaction failed

Use the value of the error property to present a message to the user.

사용자에게 메시지를 표시하는 오류 속성의 값을 사용합니다.

SKPaymentTransactionStatePurchased

Transaction succeeded

Provide the purchased functionality.

구입 한 기능을 제공합니다.

Validate the receipt, as described in Receipt Validation Programming Guide, and download any content, as described in “Providing Purchased Content.”

로 영수증 검증 프로그래밍 가이드에 설명 된 영수증을, 검증, 및에 설명 된대로 콘텐츠를 다운로드 "를 구입 한 콘텐츠를 제공."

SKPaymentTransactionStateRestored

Transaction ready to restore

For information about restoring transactions, see Restoring Transactions.

복원 트랜잭션에 대한 자세한 내용은 트랜잭션 복원을 참조하십시오.

Listing 4-1  Responding to transaction statuses

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
            default:
                break;
        }
    }
}

To keep your user interface up to date while waiting, the transaction queue observer can implement optional methods from the SKPaymentTransactionObserverprotocol as follows. The paymentQueue:removedTransactions: method is called when transactions are removed from the queue—in your implementation of this method, remove the corresponding items from your app’s UI. The paymentQueue:restoreCompletedTransactionsFailedWithError: orpaymentQueueRestoreCompletedTransactionsFinished: method is called when Store Kit finishes restoring transactions, depending on whether there was an error. In your implementation of these methods, update your app’s UI to reflect the success or error.

기다리는 동안 최신 사용자 인터페이스를 유지하려면, 트랜잭션 큐 관찰자는 다음과 같이 SKPaymentTransactionObserverprotocol에서 선택적 방법을 구현할 수 있습니다.paymentQueue : removedTransactions : 트랜잭션에서 제거 될 때 메서드가 호출 대기열이 메소드의 구현, 앱의 UI에서 해당 항목을 제거합니다.paymentQueue : restoreCompletedTransactionsFailedWithError : orpaymentQueueRestoreCompletedTransactionsFinished : 스토어 키트 복원 트랜잭션을 완료 할 때 방법은 오류가 발생했습니다 여부에 따라 호출됩니다. 이러한 방법의 구현에 성공 또는 오류를 반영하는 앱의 UI를 업데이트합니다.

Persisting the Purchase
구매를 지속

After making the product available, your app needs to make a persistent record of the purchase, to ensure that it continues to make the product available to the user in the future. Depending on the product’s type and the versions of iOS your app supports, you may need to explicitly persist the purchases or the system may handle this for you.

제품을 사용할 수 있도록 한 후, 응용 프로그램은 미래의 사용자가 사용할 수있는 제품을 만들기 위해 계속하기 위해, 구입의 영구적 인 기록을 확인해야합니다. 제품의 종류와 IOS 앱이 지원의 버전에 따라 명시 적으로 구매를 유지하거나 시스템이이 작업을 처리 할 수 ​​필요가 있습니다.

  • Consumable products. Your app updates its internal state to reflect the purchase, but there is no need to keep a persistent record because consumable products are not restored or synced across devices. Ensure that the updated state is part of an object that supports state preservation or that you manually preserve the state across app launches. For information about state preservation, see “State Preservation and Restoration” in iOS App Programming Guide.
    소모품 제품. 앱 업데이트는 내부 상태는 구입을 반영하지만, 소모품 제품은 복원 또는 장치를 통해 동기화되지 않기 때문에 영구적 인 기록을 유지 할 필요가 없습니다. 업데이트 된 상태가 상태를 보존하거나 수동으로 응용 프로그램 출시를 통해 상태를 유지하는 기능을 지원하는 오브젝트의 일부인지 확인합니다. 상태 보존에 대한 자세한 내용은 IOS 앱 프로그래밍 가이드에서 "국가 보존 및 복원"을 참조하십시오.

  • Non-consumable products, auto-renewable subscriptions, and free subscriptions. In iOS 7 and later, the system persists non-consumable products in the app receipt for you. If you need to support older versions of iOS, your app is responsible for keeping a persistent record of the purchase.
    비 소모품 제품, 자동 재생 구독 및 무료 구독. IOS 7 및 이후 버전에서, 시스템은 당신을 위해 응용 프로그램 영수증이 아닌 소모품 제품을 계속. 당신의 iOS 이전 버전을 지원해야하는 경우, 귀하의 응용 프로그램은 구입의 지속적인 기록을 유지하는 책임이 있습니다.

  • Non-renewing subscriptions. Persisting the purchase is your app’s responsibility on all versions of iOS and OS X. Store the receipt outside the device so that you can restore transactions across devices.
    구독을 비 갱신. 구입을 지속하는 것은 IOS와 OS X의 저장 장치 외부의 영수증이 장치에서 트랜잭션을 복원 할 수 있도록 모든 버전의 앱의 책임입니다.

Information about consumable products and non-renewing subscriptions is added to the receipt when they are paid for, and remains in the receipt until you finish the transaction. After you finish the transaction, this information is removed the next time the receipt is updated—for example, the next time the user makes a purchase.

소모품 제품 및 비 갱신 등록에 대한 정보는 그들이 지불 할 때 영수증을 추가, 당신은 트랜잭션을 완료 할 때까지 영수증에 남아 있습니다. 당신이 거래를 완료 한 후,이 정보는 영수증 업데이트 -입니다 예를 들어 다음 번에 제거되고 다음 번에 사용자가 구매를합니다.

For information about the app’s receipt, including how to read it and how to validate it, see Receipt Validation Programming Guide

을 읽고이를 확인하는 방법을 방법을 포함하여 응용 프로그램의 접수에 대한 자세한 내용은, 영수증 유효성 검사 프로그래밍 가이드를 참조하십시오

Persisting Using User Defaults or iCloud

사용자 기본값을 사용하거나 iCloud를 지속

The User Defaults system is the simplest approach, but it doesn’t sync across devices. In OS X, because users can edit the user defaults using Terminal, it may be more appropriate for your app to store a copy of the receipt in the user defaults—the receipt is signed and can’t be tampered with, unlike simple Boolean or integer values.

사용자 기본 시스템은 간단한 방법이지만, 그것은 장치에 걸쳐 동기화되지 않습니다. 사용자가 터미널을 사용하여 사용자 기본 설정을 편집 할 수 있기 때문에 OS X에서, 사용자의 영수증의 사본을 저장하기 위해 응용 프로그램에 더 적합 할 수 있습니다 기본값 - 영수증 간단한 부울 또는 달리 서명하고 조작 할 수 없습니다 정수 값.

To persist the purchase with the User Defaults system, set the value of a key.
사용자 기본 시스템과 함께 구입을 유지하려면 키의 값을 설정합니다.

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
 
// Store a simple value.
[defaults setBool:YES forKey:@"enable_rocket_car"];
[store setInteger:@15 forKey:@"highest_unlocked_level"];
 
// Update an array of receipts.
NSArray * receipts = [defaults arrayForKey@"receipts"];
NSData * newReceipt;  // Assume this exists.
NSArray * updatedReceipts = [receipts arrayByAddingObject:newReceipt];
[defaults setObject:newReceipts forKey@"receipts"];
 
[defaults synchronize];

To persist the purchase with iCloud, set the value of a key in the key-value store—the code in this approach is almost identical to the code for using the User Defaults system except you use an instance of NSUbiquitousKeyValueStore instead of NSUserDefaults.

iCloud를 함께 구입을 유지하려면, 키의 값을 설정 키 - 값 저장소 -이 방법의 코드는 NSUbiquitousKeyValueStore 대신 NSUserDefaults의 인스턴스를 사용하여 제외하고 사용자 기본 시스템을 사용하는 코드와 거의 동일합니다.

NSUbiquitousKeyValueStore * store = [NSUbiquitousKeyValueStore defaultStore];
 
// Store a simple value.
[store setBool:YES forKey:@"enable_rocket_car"];
[store setInteger:@15 forKey:@"highest_unlocked_level"];
 
// Update an array of receipts.
NSArray * receipts = [store arrayForKey@"receipts"];
NSData * newReceipt;  // Assume this exists.
NSArray * updatedReceipts = [receipts arrayByAddingObject:newReceipt];
[store setArray:newReceipts forKey@"receipts"];
 
[store synchronize];

Persisting Using Your Own Server
자신의 서버를 사용하여 지속

To store the receipts on your server, send a copy of the receipt to your server along with some kind of credentials or identifier so that you can keep track of which receipts belong to a particular user. For example, let users identify themselves to your server with an email or user name, plus a password. Don’t use theidentifierForVendor property of UIDevice—you can’t use it to identify and restore purchases made by the same user on a different device, because different devices have different values for this property.

당신은 영수증은 특정 사용자에게 속한 추적 할 수 있도록 서버에 영수증을 저장하려면 자격 증명 또는 식별자의 일종과 함께 서버에 영수증 사본을 보내드립니다. 예를 들어, 사용자가 이메일 또는 사용자 이름, 플러스 암호로 서버에 자신을 식별 할 수 있습니다. 의 theidentifierForVendor 속성을 사용하지 마십시오 UIDevice를 사용하면 다른 장치가이 속성에 대해 다른 값을 가지고 있기 때문에, 다른 장치에 동일한 사용자에 의해 구매를 확인하고 복원하는 데 사용할 수 없습니다.

Making the Product Available
제품이 사용 가능하게 만들기

Your app needs to take the appropriate actions to make the purchased product available to the user—unlock new app functionality, perform the purchased service, download now content, and so on. The exact details of how you make a product available depend on your app and the product.

앱이 사용자 잠금 해제 새로운 응용 프로그램 기능에 구입 한 제품을 사용할 수 있도록 적절한 조치를 취할 필요가 구입 한 서비스를 수행, 지금은 콘텐츠를 다운로드, 등등.정확한 ​​사용 가능한 제품이 귀하의 응용 프로그램과 제품에 따라 만드는 방법에 대한 자세한.

If the product has associated content, your app needs to deliver that content to the user. For example, purchasing a level in a game requires delivering the files that define that level, and purchasing additional instruments in a recording app requires delivering the sound assets that the app needs to let the user play those instruments. For information about how to provide content, see “Providing Purchased Content.”

제품의 내용을 연결 한 경우, 귀하의 응용 프로그램은 사용자에게 콘텐츠를 제공 할 필요가있다. 예를 들어, 게임에서 레벨을 구입하면 해당 레벨을 정의하는 파일을 제공하고, 레코딩 응용 프로그램에 추가로 장비를 구입해야합니다 응용 프로그램은 사용자가 해당 악기를 연주하도록해야한다는 소리가 자산을 제공해야합니다. 콘텐츠를 제공하는 방법에 대한 자세한 내용은 "구입 한 컨텐츠를 제공"을 참조하십시오.

Finishing the Transaction
거래를 마무리

Finishing a transaction tells Store Kit that you have completed everything needed for the purchase. Unfinished transactions remain in the queue until they are finished, and the transaction queue observer is called every time your app is launched so that your app can finish them.
트랜잭션을 완료하는 것은 당신이 구입에 필요한 모든 것을 완료했다고 스토어 키트를 알려줍니다. 끝나지 않은 트랜잭션들이 완료 될 때까지 큐에 남아 있고, 트랜잭션 큐 관찰자는 앱이 앱이 그들을 완료 할 수 있도록 실행 때마다 호출됩니다.

Complete all the following actions before you finish the transaction:
당신이 거래를 완료하기 전에 다음 작업을 완료합니다 :

  • Persist the purchase if needed.
    필요한 경우 구입을 지속.

  • Download any purchased content.
    모든 구입 한 콘텐츠를 다운로드합니다.

  • Update your app’s UI to let the user access the product.
    사용자가 제품에 액세스 할 수 있도록 앱의 UI를 업데이트합니다.

  • Finish any other work needed to deliver the product.
    제품을 제공하는 데 필요한 다른 작업을 마칩니다.

To finish a transaction, call its finishTransaction: method. After you finish a transaction, do not take any actions on that transaction or do any work to deliver the product. If there is work remaining on a transaction, your app isn’t ready to finish the transaction yet.

방법 : 트랜잭션을 완료하려면 해당 finishTransaction를 호출합니다. 트랜잭션을 완료 한 후, 해당 트랜잭션에 대한 작업을 수행하거나 제품을 제공 할 수있는 작업을 수행하지 않습니다. 트랜잭션에 남은 작업이있는 경우, 당신의 앱은 아직 트랜잭션을 완료 할 준비가되지 않습니다.

Suggested Testing Steps
제안 된 테스트 단계

Test each part of your code to verify that you have implemented it correctly.
당신이 올바르게 구현되었는지 확인하는 코드의 각 부분을 테스트합니다.

Test a Successful Transaction
성공적인 트랜잭션을 테스트

Sign in to the iTunes Store with a test user account, and make a purchase in your app. Set a breakpoint in your implementation of the transaction queue observer’spaymentQueue:updatedTransactions: method, and inspect the transaction to verify that its status is SKPaymentTransactionStatePurchased.

테스트 사용자 계정을 사용하여 iTunes Store에 로그인하고 응용 프로그램에 구매를합니다. updatedTransactions : 트랜잭션 큐 observer'spaymentQueue의 구현에서 중단 점 설정 방법, 그 상태가 SKPaymentTransactionStatePurchased되어 있는지 확인하기 위해 트랜잭션을 검사합니다.

Set a breakpoint at the point in your code that persists the purchase, and confirm that this code is called in response to a successful purchase. Inspect the User Defaults or iCloud Key-Value Store, and confirm that the correct information has been recorded.

구입을 계속 코드의 시점에서 중단 점을 설정하고,이 코드가 성공적으로 구매에 대한 응답으로 호출되어 있는지 확인합니다.사용자 기본값 또는 iCloud에 키 - 값 저장소를 점검하고 올바른 정보가 기록되었는지 확인합니다.

Verify That Transactions Are Finished
트랜잭션이 완료되어 있는지 확인합니다

Locate where your app calls the finishTransaction: method. Verify that all work related to the transaction has been completed before the method is called, and that the method is called for every successful purchase.

방법 : 앱이 finishTransaction 호출 위치를 찾습니다.메서드를 호출하기 전에 거래에 관련된 모든 작업이 완료되었는지, 그리고 방법은 모든 성공적인 구입이라고되어 있는지 확인합니다.

Posted by 창업자닉군
,