Ios spesific价格层的本地AppStore货币作为变量?
我正在尝试在appstore中为我们自己的一个附加应用创建自定义“广告”。一切都很完美,但在广告中我们现在写的是Ios spesific价格层的本地AppStore货币作为变量?,ios,cocoa-touch,localization,app-store,currency,Ios,Cocoa Touch,Localization,App Store,Currency,我正在尝试在appstore中为我们自己的一个附加应用创建自定义“广告”。一切都很完美,但在广告中我们现在写的是NSLog(@“只需0.99美元”) 如何根据本地“登录”应用商店将其设置为变量?我觉得应该是这样的: NSString *price = [something localPriceForTier:1]; NSLog(@"For only %@", price); 它会说,无论用户基于什么货币和价值,我发送的价格层都是1。我想我以前见过这样的应用程序,但我不知道该搜索什么。设备上没有
NSLog(@“只需0.99美元”)代码>
如何根据本地“登录”应用商店将其设置为变量?我觉得应该是这样的:
NSString *price = [something localPriceForTier:1];
NSLog(@"For only %@", price);
它会说,无论用户基于什么货币和价值,我发送的价格层都是1。我想我以前见过这样的应用程序,但我不知道该搜索什么。设备上没有保存信息,如果需要,你必须获取这些信息。因此,您要做的是创建一个具有适当产品标识符的,等待您的学员获得一个合适的,您可以从中获得合适的,并且您可以使用带有数字格式化程序的price
和priceLocale
来获取带有适当货币符号的本地价格字符串。在SKProduct
文档中有一个简单的示例代码。据我所知,Store Kit没有任何要求通用价格层的功能。您必须询问您的产品的当前本地价格。下面是一些代码:
- (void) requestProductData
{
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:
[NSSet setWithObject: yourProductIdentifier]];
request.delegate = self;
[request start];
}
回调函数:
- (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);
}
上述代码片段在官方的应用程序内购买编程指南中有详细解释:那么“pro”版本必须经过批准并在AppStore上才能使用此功能?