确定与登录iOS设备的Apple ID关联的国家/地区 [英] Determine Country associated with Apple ID logged into the iOS device

查看:363
本文介绍了确定与登录iOS设备的Apple ID关联的国家/地区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个特定的场景,其中一些内容(来自服务)需要根据位置或用户所在的国家/地区显示。

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)使用NSLocale

1) Using NSLocale

NSLocale * locale = [NSLocale currentLocale];
NSString * countryCode = [locale objectForKey:NSLocaleCountryCode];

缺点:可由用户更改,可通过设置 - >常规 - >国际 - >区域格式

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)使用核心位置

确定纬度&经度(CLLocationManager& CLLocation)。从纬度和纬度经度使用反向地理编码确定国家/地区。
似乎是我最准确的服务目的。

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.

缺点:如果用户不允许核心位置服务找不到lat&很长,再次依赖于用户。

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

以下是我的几个问题

1)我想知道是否APPLE提供的API可以帮助我了解购买我的应用程序的Apple ID以及Apple ID所属的国家/地区吗?

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)考虑到Apple的安全环境,这可能是非常不可能的,但仍然......是否可以将与信用卡相关联的国家(如果关联)与Apple ID相关联?

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?

等待回复。

全部谢谢。

推荐答案

答案两个问题都没有(有充分的理由)。 Apple不提供对设备所有者Apple ID的编程访问权限。当然也没有与信用卡相关的任何信息。我会询问用户获取其位置的权限并解释您的应用程序需要它的原因(在iOS 6中,您可以提供请求位置的原因的上下文)。

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

这篇关于确定与登录iOS设备的Apple ID关联的国家/地区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆