开发者

How to find out which territory's App Store the running app came from?

开发者 https://www.devze.com 2023-03-01 01:41 出处:网络
Is there a way o开发者_如何学编程f working out which territory\'s App Store the running app came from?

Is there a way o开发者_如何学编程f working out which territory's App Store the running app came from?

I would like to set certain preferences and links in the app according to the territory it is being used in, and I would prefer not to use the GPS if possible.

At the moment our best bet seems to be to examine the phone's locale.


It's possible to get user's appstore country when your app finish request IAP products.

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    NSArray *products = response.products;
    SKProduct *product = products.lastObject;

    if (product) {
        NSLocale* storeLocale = product.priceLocale;
        // Get it!
        NSString *storeCountry = (NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);

    }
}


Using the device's current locale would be the proper way to do this.

There is no way you can find out which app store region the app was downloaded from.

Also, the locale will tell you which language/region settings the user prefers, where the GPS or current location would only tell you where they are.

For example, I have my iPhone set to the United Kingdom as the locale, but I may go on holiday to France. If I downloaded an app while in France, I wouldn't want it to be set up for French users just because that's where I am.

The locale is a user chosen preference, it doesn't change as the user changes location.

0

精彩评论

暂无评论...
验证码 换一张
取 消