Programmatically detect which app store the app was downloaded from

后端 未结 3 2094
星月不相逢
星月不相逢 2020-12-29 11:28

I haven\'t found a thread about this so I must ask: is there a way to programmatically detect which app store the app was downloaded from? (ie: Germany App Store)

I

相关标签:
3条回答
  • 2020-12-29 12:09

    I think you'd use the current locale of the user to detect in which country they are… but it could fail sometimes, so I'm not very sure if a not 100% effective way to detect the AppStore would work for you.

    You'd need to call

    [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode]
    

    Also, please see discussions in the following threads, some of them are old, but probably will help you to find alternatives solutions too Link1 and Link2

    0 讨论(0)
  • 2020-12-29 12:10

    If you have In App Purchases you can check the priceLocale of your SKProduct, which gives you the store (currency and country) the user currently is logged in.

    Apple recommended this at WWDC2014 Session 303 Optimizing In-App Purchases at 10:30.

    0 讨论(0)
  • 2020-12-29 12:17

    the NSLocale answer is wrong as the system language settings don't have to match the app store country. some users buy in foreign stores because more content is available. using StoreKit/SKProduct probably works, but is available only for apps distributed in the store.

    if you are on the Mac, you can just parse a config file of the Mac App Store directly as done here: https://github.com/core-code/CoreLib/blob/master/Mac/JMHostInformation.m in the "appStoreCountryCode" method

    0 讨论(0)
提交回复
热议问题