iOS Developer Library/Guides

Displaying Your App’s Store UI, iOS In-App Purchase Programming Guide 번역

창업자닉군 2013. 9. 19. 09:48

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 문서의 Displaying Your App’s Store UI 부분을 번역해 놓은 페이지 입니다. 발 번역이라 이상한 부분이 있을 수 있습니다. 발견즉시 댓글을 달아 주세요.




Displaying Your App’s Store UI
귀하의 응용 프로그램의 저장소 UI를 표시

In the first part of the purchase process, your app presents its store UI to the user, and then lets the user selects a product, as shown in Figure 2-1. The second and third part of the process are described in the two chapters that follow this one.

구매 프로세스의 첫 번째 부분에서는 여러분의 응용 프로그램은 사용자에게 자사의 매장 UI를 제공하고 그림 2-1과 같이 사용자가 제품을 선택 할 수 있습니다. 프로세스의 두 번째 및 세 번째 부분은이 하나를 따라 두 장에 설명되어 있습니다.

Figure 2-1  Stages of the purchase process—displaying store UI



Getting a List of Product IDs
제품 ID 목록 가져 오기

To get a list of product identifiers, have your app either read them from a file in your app bundle or fetch them from your server. Table 2-1 summarizes the differences between the two approaches. If you offer a fixed list of products, such as an in-app purchase to remove ads, embed the list in your app bundle. If your list of product identifiers can change without you updating your app, have your app fetch the list from your server.

제품 식별자의 목록을 얻으려면, 당신의 애플 리케이션 중 하나를 귀하의 응용 프로그램 번들에 파일을 읽거나 서버에서 그들을 가져올 수 있습니다. 표 2-1은 두 가지 방식의 차이점을 요약 한 것입니다. 당신은 광고를 제거하는 등의 앱내 구매로 제품의 고정 된 목록을 제공하는 경우, 귀하의 응용 프로그램 번들의 목록을 포함합니다. 제품 식별자의 목록이 앱을 업데이트하지 않고 변경할 수없는 경우 응용 프로그램이 서버에서 목록을 가져올 수 있습니다.

Table 2-1  Comparison of approaches for obtaining product identifiers

Embedded in the app bundle

Fetched from your server

Used for purchases that

Unlock functionality

Deliver content

List of products can change

When the app is updated

At any time

Requires a server

No

Yes

There is no runtime mechanism to fetch a list of all products configured for an app in iTunes Connect. You are responsible for managing your app’s list of products and providing that information to your app.

연결 iTunes에서 응용 프로그램에 대해 구성된 모든 제품의 목록을 가져 오기하는 런타임 메커니즘은 없습니다. 당신이 제품의 응용 프로그램의 목록을 관리하고 응용 프로그램에 해당 정보를 제공 할 책임이 있습니다.

Embedding Product IDs in the App Bundle
앱 번들 제품 ID를 포함

Include a property list file in your app bundle containing an array of product identifiers, such as the following:
다음과 같은 제품 식별자의 배열을 포함하는 응용 번들 프로퍼티리스트 파일을 포함합니다 :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>com.example.level1</string>
    <string>com.example.level2</string>
    <string>com.example.rocket_car</string>
</array>
</plist>

To get product identifiers from the property list, locate the file in the app bundle and read it.
속성 목록에서 제품 ID를 얻으려면 응용 프로그램 번들에 파일을 찾아 그것을 읽고.

NSURL * url = [[NSBundle mainBundle] URLForResource:@"product_ids"
                                     withExtension:@"plist"];
NSArray * productIdentifiers = [NSArray arrayWithContentsOfURL:url];

Fetching Product IDs from Your Server
귀하의 서버에서 제품 ID를 가져 오기

Store a JSON file on your server with the product identifiers. For example:
제품 식별자 서버에 JSON 파일을 저장합니다. 예를 들면 :

[
    "com.example.level1",
    "com.example.level2",
    "com.example.rocket_car"
]

To get product identifiers from your server, fetch the JSON file and read it.
서버에서 제품 ID를 얻으려면, JSON 파일을 가져오고 그것을 읽고.

-fetchProductIdentifiersFromURL:(NSURL*)url delegate(id):delegate
{
    dispatch_queue_t global_queue =
           dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
    dispatch_async(global_queue, ^{
        NSError * err;
        NSData * jsonData = [NSData dataWithContentsOfURL:url
                                                  options:NULL
                                                    error:&err];
        if (!jsonData) {
           // Handle the error...
        }
 
        NSArray * productIdentifiers = [NSJSONSerialization
            JSONObjectWithData:jsonData options:NULL error:&err];
        if (!productIdentifiers) {
           // Handle the error...
        }
 
        dispatch_queue_t main_queue = dispatch_get_main_queue();
        dispatch_async(main_queue, ^{
           [delegate displayProducts:productIdentifiers];
        }
    });
}

For information about downloading files using NSURLConnection, see “Using NSURLConnection” in URL Loading System Programming Guide.

NSURLConnection을 사용하여 파일을 다운로드하는 방법에 대한 자세한 내용은 URL 로딩 시스템 프로그래밍 설명서의 "사용하여 NSURLConnection"을 참조하십시오.

To ensure that your app remains responsive, use a background thread to download the JSON file and extract the list of product identifiers. To minimize the data transferred, use standard HTTP caching mechanisms, such as the Last-Modified and If-Modified-Since headers.

앱이 반응이 유지되도록하기 위해, JSON 파일을 다운로드 및 제품 식별자의 목록을 추출하기 위해 백그라운드 스레드를 사용합니다. 전송 된 데이터를 최소화하는 등 마지막으로 수정과에서 If-modified-since 헤더를 같은 표준 HTTP 캐싱 메커니즘을 사용합니다.

Retrieving Product Information
제품 정보 검색

To make sure your users see only products that are actually available for purchase, query the App Store before displaying your store UI.

사용자가 구입 사실에만 사용할 수 있습니다 제품을 볼 수 있는지 확인하려면, 당신의 상점 UI를 표시하기 전에 앱 스토어를 쿼리합니다.

Use a products request object to query the App Store. First, create an instance of SKProductsRequest and initialize it with a list of product identifiers. The products request retrieves information about valid products, along with a list of the invalid product identifiers, and then calls its delegate to process the result. The delegate must implement the SKProductsRequestDelegate protocol to handle the response from the App Store. Listing 2-1 shows a simple implementation of both pieces of code.

앱 스토어를 쿼리하는 제품 요청 개체를 사용합니다. 첫째, SKProductsRequest의 인스턴스를 생성하고 제품 식별자의리스트로 초기화합니다.제품 요청은 잘못된 제품 ID 목록과 함께, 유효한 제품에 대한 정보를 검색하고 결과를 처리하기 위해 대리자를 호출합니다.대리자는 앱 스토어에서 응답을 처리하는 SKProductsRequestDelegate 프로토콜을 구현해야합니다. 목록 2-1은 코드의 두 조각의 간단한 구현을 보여줍니다.

Listing 2-1  Retrieving product information

// Custom method
- validateProductIdentifiers:(NSArray *)productIdentifiers
{
    SKProductsRequest productsRequest = [[SKProductsRequest alloc]
        initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]];
    productsRequest.delegate = self;
    [productsRequest start];
}
 
// SKProductsRequestDelegate protocol method
- (void)productsRequest:(SKProductsRequest *)request
     didReceiveResponse:(SKProductsResponse *)response
{
    self.products = response.products;
 
    for (NSString * invalidProductIdentifier in response.invalidProductIdentifiers) {
        // Handle any invalid product identifiers.
    }
 
    [self displayStoreUI]; // Custom method
}

When the user purchases a product, you need the corresponding product object to create a payment request, so keep a reference to the array of product objects that is returned to the delegate. If the list of products your app sells can change, you may want to create a custom class that encapsulates a reference to the product object as well as other information—for example, pictures or description text that you fetch from your server.

사용자가 제품을 구입하면, 당신은 지불 요청을 만들하므로 대리자에 반환 제품 개체의 배열에 대한 참조를 유지하기 위해 해당 제품 개체가 필요합니다. 앱이 판매하는 제품의 목록을 변경할 수 있다면, 당신은 당신의 서버에서 가져올 수있는 제품 객체에 대한 참조뿐만 아니라 다른 정보 예를 들어, 사진이나 설명 텍스트를 캡슐화하는 사용자 정의 클래스를 만들 수 있습니다.

The way you handle invalid product identifiers depends on where the list of product identifiers came from. If your app loaded the list from its app bundle, log a note to aid debugging and ignore the invalid identifiers. If your app fetched the list from your server, let your server know which product identifiers were invalid. As with all other interactions between your app and your server, the details and mechanics of this are up to you.

당신이 잘못된 제품 식별자를 처리하는 방법은 제품 식별자의 목록을 어디에서 왔는지에 따라 달라집니다. 앱이 자사의 애플 리케이션 번들에서 목록을로드하는 경우, 디버깅을 보조하고 유효하지 않은 식별자를 무시하는 메모를 기록합니다. 앱이 서버에서 목록을 가져온 경우, 서버 제품 식별자가 잘못된 경우 어느 알려 주시기 바랍니다. 귀하의 응용 프로그램과 서버 사이의 모든 상호 작용과 마찬가지로, 이것의 세부 사항 및 역학 당신에게 달려 있습니다.

Present Your Store UI
당신의 상점 UI를 제시

The design of your store has an import impact on your in-app sales, so it’s worth investing the time and effort to get it right. Design the user interface for your app’s store so that it integrates with the rest of your app. Store Kit can’t provide a store UI for you. Only you know your app and its content well enough to design your store UI so it showcases your products in their best light and integrates with the rest of your app.

상점의 디자인은 당신의 앱에서 판매에 수입 영향을, 그래서 시간과 바로 그것을 얻기 위해 노력을 투자 가치가있다. 당신의 응용 프로그램의 나머지 부분과 통합되도록 응용 프로그램의 저장소에 대한 사용자 인터페이스를 디자인합니다. 스토어 키트는 당신을 위해 저장소 UI를 제공 할 수 없습니다. 오직 당신 만이 당신의 애플 리케이션 그것이 최선 빛에있는 당신의 제품을 전시하고 응용 프로그램의 나머지 부분과 통합 그래야 당신의 상점 UI를 설계하는 충분히 그 내용을 알고있다.

Consider the following guidelines as you design and implement your app’s store UI:
당신은 당신의 애플 리케이션의 상점 UI를 설계하고 구현으로 다음과 같은 지침을 고려

Display a store only if the user can make payments. To determine whether the user can make payments, call the canMakePayments class method of theSKPaymentQueue class. If the user can’t make payments (for example, because of parental restrictions), either tell the user that the store is not currently supported (by displaying appropriate UI) or omit the store portion of your UI entirely.

사용자가 지불 할 수있는 경우에만 저장소를 표시합니다.사용자가 지불 할 수 있는지 여부를 확인하려면, theSKPaymentQueue 클래스의 canMakePayments 클래스 메서드를 호출합니다.사용자가 지불 (예를 들어,이 부모의 제한)를 할 수없는 경우, 저장소가 현재 지원되지 않는 사용자에게 알려 (해당 UI를 표시하여) 또는 전적으로 UI의 저장 부분을 생략하거나.

Expose as much information about a product as possible. Users want to know exactly what they’re going to buy. If possible, let users interact with a product. For example, a game that lets the user buy new characters can let users run a short course as the new character. Likewise, a drawing app that lets the user buy additional brushes can let users draw with the new brush on a small scratch pad. This kind of design gives users an opportunity to experience the product and be convinced they want to buy it.

가능한 한 제품에 대한 많은 정보를 노출합니다. 사용자는 살거야 정확히 알고 싶어요. 가능하면, 사용자가 제품과 상호 작용할 수 있습니다. 예를 들어, 사용자가 새로운 캐릭터를 구입할 수있는 게임은 사용자가 새로운 캐릭터로 짧은 과정을 실행할 수 있습니다. 마찬가지로, 사용자가 추가로 브러쉬를 살 수있는 드로잉 응용 프로그램은 사용자가 작은 스크래치 패드에 새로운 브러시로 그릴 수 있도록 할 수 있습니다. 디자인의이 종류는 사용자에게 제품을 경험하고 그들은 그것을 사고 싶은 확신 할 수있는 기회를 제공합니다.

Use the properties of your product objects to populate your store’s user interface. Their properties give you information such as the product’s price and its description. Combine this with additional data from your server or the app bundle, such as images or demos of your products.

상점의 사용자 인터페이스를 채울 제품 개체의 속성을 사용합니다. 그들의 속성은 당신에게 같은 제품의 가격 및 설명과 같은 정보를 제공합니다. 이러한 이미지 또는 제품의 데모와 같은 서버 또는 응용 프로그램 번들에서 추가 데이터를 사용하여이 작업을 결합합니다.

Display prices using the locale and currency returned by the store. Don’t try to convert the price to a different currency in your UI, even if the user’s locale and the price’s locale are different. Consider, for example, an English-speaking user in China who pays for purchases with a Chinese credit card but prefers the US English locale settings for apps. You app would display its UI according to the user’s locale, using US English as requested by the user. It would display prices according to the products’ locale, using the currency that corresponds to the Chinese locale (renminbi) with that locale’s formatting. Converting the prices to US dollars (to match the US English locale) would be misleading because the user is billed in renminbi, not US dollars. Listing 2-2 shows how to correctly format a price using the product’s locale information.

저장소에서 반환 된 로케일과 통화를하여 가격을 표시합니다.사용자의 로케일과 가격의 로케일이 다른 경우에도 UI에서 다른 통화로 가격을 변환하려고하지 마십시오. 예를 들어, 중국 신용 카드로 구매를 위해 지불하지만, 애플 리케이션을위한 영어 (미국) 로케일 설정을 선호하는 중국에서 영어 사용을 고려하십시오. 당신이 애플 리케이션은 사용자가 요청한 미국 영어를 사용하여 사용자의 로케일에 따라 자사의 UI를 표시합니다. 그것은 그 로케일의 서식 중국어 로케일 (인민폐)에 해당하는 통화를 사용하여 제품의 로케일에 따라 가격을 표시한다.사용자가 위안화가 아닌 달러에 청구되기 때문에 달러 (미국 영어 로캘과 일치하는)에 가격을 변환하는 것은 잘못된 것입니다. 목록 2-2 정확하게 제품의 로케일 정보를 사용하여 가격을 포맷하는 방법을 보여줍니다.

Listing 2-2  Formatting a product’s price

NSNumberFormatter * numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
NSString * formattedPrice = [numberFormatter stringFromNumber:product.price];

After a user selects a product to buy, your app connects to the store to request payment for the product.

사용자가 구입할 수있는 제품을 선택 한 후, 응용 프로그램은 제품에 대한 지불을 요청하는 저장소에 연결합니다.