我们有一个iOS应用程序与应用程序内购买,我们希望跟踪与谷歌分析(增强电子商务)的交易。我们已经对priceLocal有了正确的处理,这不是问题.我们需要告诉GA用户正在使用的特定货币代码。这个信息似乎并不是直接可用的,我们宁愿不自己查找。
现行代码摘要:
// Set locale
NSLocale *storeLocale = product.priceLocale;
// instead of storeCountry we need storeCurrency, like USD, CAD, EUR, GBP...
NSString *storeCountry = (NSString *)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);
[ecommerced setObject:storeCountry forKey:@"currencyCode"];发布于 2015-12-01 19:49:14
我没有运行这段代码来查看它是否有效,但这是如何得到您想要的东西的。
NSNumberFormatter *formatter = [NSNumberFormatter new];
[formatter setNumberStyle: NSNumberFormatterCurrencyStyle];
[formatter setLocale: storeLocale];
NSLog("The currency code is: %@", formatter.currencyCode);https://stackoverflow.com/questions/34027733
复制相似问题