Determine Country associated with Apple ID logged into the iOS device

蹲街弑〆低调 提交于 2019-12-22 08:19:52

问题


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.


回答1:


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).




回答2:


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.



来源:https://stackoverflow.com/questions/12673351/determine-country-associated-with-apple-id-logged-into-the-ios-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!