2013-01-24 25 views
2

我試圖在appstore中爲我們自己的其他應用之一創建自定義「廣告」。一切都很完美,但在廣告中我們現在正在寫NSLog(@"For only $0.99"); 如何根據本地「登錄」appstore將其作爲變量?我想它應該是這個樣子:作爲變量的特定價格層的本地AppStore貨幣?

NSString *price = [something localPriceForTier:1]; 
NSLog(@"For only %@", price); 

而且它會說這是什麼貨幣和值,其中用戶是基於該價格區間我送爲1。我想我我以前看過這個應用程序,但我不知道該搜索什麼。

回答

2

據我所知,Store Kit沒有任何功能要求通用價格層。您必須要求您的某個產品的當前當地價格。下面是一些代碼:

- (void) requestProductData 
{ 
    SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: 
      [NSSet setWithObject: yourProductIdentifier]]; 
    request.delegate = self; 
    [request start]; 
} 

回調函數:http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008267

+0

所以「親」的版本有:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { NSArray *myProducts = response.products; SKProduct *product = [myProducts objectAtIndex:0]; NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [numberFormatter setLocale:product.priceLocale]; NSString *formattedString = [numberFormatter stringFromNumber:product.price]; NSLog(@"For only %@", formattedString); } 

上面的片斷進行了詳細的應用程序內購買編程指南官方解釋要獲得批准並在AppStore上使用'lite'版本才能使用此功能? – Sti

+0

@Sti是的,應用程序必須清除在商店出售。 –

1

該信息未保存在設備上,如果您需要,您必須提取該信息。因此,您要做的是創建一個帶有適當產品標識符(您可以從iTunes Connect獲得)的SKProductsRequest,等到您的代理商獲得合適的SKProductsResponse,從中您可以獲得相應的SKProduct,並且您可以使用pricepriceLocale那裏有一個數字格式化程序,用適當的貨幣符號得到一個當地價格的字符串。 SKProduct文檔中有一小段示例代碼。