【问题标题】:iOS app with iTunes store - get currency code (not priceLocal)带有 iTunes 商店的 iOS 应用程序 - 获取货币代码(不是 priceLocal)
【发布时间】:2015-12-01 18:43:15
【问题描述】:

我们有一个带有应用内购买功能的 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"];

【问题讨论】:

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


    【解决方案1】:

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

    NSNumberFormatter *formatter = [NSNumberFormatter new];
    [formatter setNumberStyle: NSNumberFormatterCurrencyStyle];
    [formatter setLocale: storeLocale];
    
    NSLog("The currency code is: %@", formatter.currencyCode);
    

    NSNumberFormatter Documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      • 2014-12-07
      • 1970-01-01
      • 2017-03-02
      • 1970-01-01
      相关资源
      最近更新 更多