1

We have an iOS app with in-app purchase and we want to track transactions with Google Analytics (enhanced ecommerce). We already have the proper handling for priceLocal, that's not the issue... we need to tell GA the specific currency code in use by the user. This info doesn't seems to be available directly and we would rather not do our own lookup.

Current code abstract:

// 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"];
4

1 回答 1

2

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

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

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

NSNumberFormatter 文档

于 2015-12-01T19:49:14.670 回答