steven
steven

Reputation: 1275

Can I know the region of iOS App Store that my app downloaded from?

I'm an iOS developer.

Recently I was informed that I need to remove Callkit from my app in China region. But I can't just release a Chinese version without Callkit that separated from the original app. Because our server end has already been sold to customers, I am not able to alter the apple push certificate for them one by one. So I need to identify the China region in runtime.

Using location is not a good idea since our app has nothing to do with user's location and it can be easily turned off in settings. Is it possible to know the region of App Store that my app was originally downloaded from in runtime?

Thank you.

Upvotes: 1

Views: 2311

Answers (2)

grebulon
grebulon

Reputation: 7972

Check the storefront from storekit

#import <StoreKit/StoreKit.h>
SKStorefront *store = [[SKPaymentQueue defaultQueue] storefront];
if ([store.countryCode isEqualTo:@"CHN"]) {
    // is China
}

Upvotes: 0

txulu
txulu

Reputation: 1792

What about checking the locale region? It sounds stupid and very easy to circumvent but it might be good enough to fulfil the chinese legal requirements... Something in the lines of:

// Chinese country codes
NSString *const MacauChinaCountryCode = @"MO";
NSString *const ChinaCountryCode = @"CN";
NSString *const HongKongChinaCountryCode = @"HK";

...

- (BOOL)isRegionSupportedByCallKit {
    NSString *currentCountryCode = [NSLocale currentLocale].countryCode;
    NSArray<NSString *> *chineseCountryCodes = @[MacauChinaCountryCode, ChinaCountryCode, HongKongChinaCountryCode];
    return ![chineseCountryCodes containsObject:currentCountryCode];
}

Upvotes: 1

Related Questions