带有 iTunes 商店的 iOS 应用程序 - 获取货币代码(不是 priceLocal)

标签 ios google-analytics google-tag-manager itunes-store google-analytics-sdk

我们有一款支持应用内购买的 iOS 应用,我们希望通过 Google Analytics(增强型电子商务)跟踪交易。我们已经对 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"];

最佳答案

我还没有运行这段代码来查看它是否有效,但这是获得你想要的东西的方法。

NSNumberFormatter *formatter = [NSNumberFormatter new];
[formatter setNumberStyle: NSNumberFormatterCurrencyStyle];
[formatter setLocale: storeLocale];

NSLog("The currency code is: %@", formatter.currencyCode);

NSNumberFormatter Documentation

关于带有 iTunes 商店的 iOS 应用程序 - 获取货币代码(不是 priceLocal),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34027733/

相关文章:

android - 使用英特尔 XDK 的跨平台样式

ios - 从 appDelegate 转至 View Controller

ios - 无法使用 AVAudioPlayer 播放存储在文档目录中的本地 mp3 文件

ajax - 在没有事件的情况下将动态数据发送到 Google 标签管理器 dataLayer

google-analytics - 访问 Google Analytics 时出现 "Resource not available. Please try again later"错误

javascript - Google 跟踪代码管理器 - 页脚中的脚本怎么样?

ios - 从文件中重新加载 NSStrings 的 NSArray

ios - iphone - 如何使用 Google Analytics EasyTracker 跟踪事件?

regex - 正则表达式以查看ip是否以156.21.x.x开头

facebook - 在 Google Analytics 中获取 Facebook 推荐 URL