我有一个使用In-App-Purchase的iOS应用程序,可以满足国际受众的需求,所以我希望以不同的货币付款(美元,欧元,人民币......,你从AppStore定价矩阵中了解它们)。当然我想用用户的本地货币显示购买的商品,但我真的不知道如何。
使用用户的区域或语言似乎是一个糟糕的指标,因为货币取决于用户正在使用的AppStore帐户的区域而不是设备设置。
如何找出用户将支付的货币?
答案 0 :(得分:31)
获取SKProduct对象后,您可以从price和priceLocale属性构建其本地化价格。这是来自apple docs的复制粘贴如何做到这一点:
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
NSString *formattedString = [numberFormatter stringFromNumber:product.price];