Determine Country associated with Apple ID logged

2019-05-14 19:01发布

I have a particular scenario in my application where some content (coming from service) needs to be displayed based on location or say country of the user.

There are two/three ways I figured out by which I could accomplish this but they have some disadvantages as mentioned below.

1) Using NSLocale

NSLocale *locale = [NSLocale currentLocale]; NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
Disadvantage:Can be changed by user, this is configurable from Setting->General ->International->Region Format

2)Using Core Location

Determine the latitude & longitude (CLLocationManager & CLLocation). From the latitude & longitude determine the country using Reverse Geocoding. Seems to me the most accurate way of serving my purpose.

Disadvantage:If the user doesn't allow core location services can't find lat & long, again user dependent.

Here are my couple of questions

1)I would like to know if there is an API available from APPLE that helps me know the Apple ID through which my application was purchased and in-turn the country to which this Apple ID belongs?

2)This one may be highly impossible considering Apple's secure environment, but still... Is it possible to get the country associated with the Credit card (if associated) against an Apple ID?

Waiting for response.

Thanks All.

2条回答
劫难
2楼-- · 2019-05-14 19:44

You can access data about the device's SIM card using CTTelephonyNetworkInfo. Of course that works only if the user has a SIM card. And it's of dubious value, since most people are allowed to travel to most places on the earth.

查看更多
一纸荒年 Trace。
3楼-- · 2019-05-14 19:48

Answers to both questions is no (for good reasons). Apple does not provide programmatic access to the device owner's Apple ID. And certainly not any info associated to the credit card. I would go with asking the user permission to get their location and explaining why your app needs it (in iOS 6 you can provide a context for why location is requested).

查看更多
登录 后发表回答