jan*_*pio 8 localization app-store in-app-purchase
我有一个使用In-App-Purchase的iOS应用程序,迎合了国际受众,所以我希望以不同的货币付款(美元,欧元,人民币......,你从AppStore定价矩阵中了解它们).当然我想用用户的本地货币显示购买的商品,但我真的不知道如何.
使用用户的区域或语言似乎是一个糟糕的指标,因为货币取决于用户正在使用的AppStore帐户的区域而不是设备设置.
我怎样才能知道用户将支付哪种货币?
Vla*_*mir 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];