2013-08-14 1 views
1

제목에서 알 수 있듯이 미국 App Store에서는 인앱 가격을 구입해야하며 사용자의 현재 로케일과 설정은 완전히 무시해야합니다.애플 인앱 구매 - 특정 지역의 가격 검색

다른 말로하면,
사용자가 러시아/프랑스/기타로 설정되어 있어도 제품의 미화 가격을 알아보십시오.

감사

당신이 SKProductsRequest에서 사용할 수 필요한 것은
+0

왜? 그러면 디스플레이는 사용자가 지불 할 가격과 다를 것입니다. – Wain

+0

애널리틱스에 필요합니다. – eladr

답변

2

. SKRequestDelegate 프로토콜을 사용하여 객체를 구현하면 가격을 얻을 수 있습니다. 원하는 경우 로캘을 미국으로 하드 코드하도록 선택할 수 있습니다.

설정하려면 요청 :

NSSet* identifiers = [NSSet setWithObjects:inAppIdentiferOne, inAppIdentifierTwo, nil]; 

SKProductsRequest* productRequest= [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers]; 
productRequest.delegate = self; 
[productRequest start]; 

가 응답을 처리하려면 다음

-(void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response 
{ 
    for(int i=0; i<response.products.count; i++) 
    { 
     SKProduct* instance = [response.products objectAtIndex:i]; 

     NSLog(@"IAP Desc: %@. Title: %@.", instance.localizedDescription, instance.localizedTitle); 

     // This is where you can hardcode the US locale by setting a NSLocale type 
     // I'm not 100% sure on how to set the NSLocale correctly, so currently this line sets localization 
     NSLocale* locale = instance.priceLocale; 

     NSNumberFormatter* fmtr = [[NSNumberFormatter alloc] init]; 
     [fmtr setNumberStyle:NSNumberFormatterCurrencyStyle]; 
     [fmtr setLocale:locale]; 

     if([instance.productIdentifier isEqualToString:inAppIdentiferOne]) 
     { 
      NSString* localizedCostString = [fmtr stringFromNumber:(instance.price)]; 
      NSString* productIdentifier = instance.productIdentifier; 
     } 
     else if([instance.productIdentifier isEqualToString:inAppIdentiferTwo]) 
     { 
      NSString* localizedCostString = [fmtr stringFromNumber:(instance.price)]; 
      NSString* productIdentifier = instance.productIdentifier; 
     } 
    } 
} 

당신은 아마 처리하는 이러한 식별자를 검색 실패를 처리 할 수있는 추가 옵션 기능이 있습니다.

+0

Brilliant! 감사합니다 – eladr

+0

이것은 단지 포맷터 (통화 기호와 스타일)가 아니라 Apple이 실제로 반환 한 데이터 (가격 번호)를 변경합니다. – Wain

+0

사실 저는 Apple이 반환 한 가격이 이미 현지화되어 있음을 알았습니다. 따라서 포맷터를 하드 코드하여 USD로 표시하면 다른 통화를 나타낼 때 일관성없는 가격이 표시됩니다. 애플이 IAP를 위해 계층 가격을 반환하지 않는다는 것은 수치스러운 일이다. – aronspring