有没有办法从iPhone SDK的标准api获得自己的电话号码?
当前回答
冒着被扣分的风险,我想建议排名最高的解决方案(目前是第一个响应)违反了2009年11月5日的最新SDK协议。我们的申请因为使用它而被拒绝了。以下是苹果公司的回应:
"For security reasons, iPhone OS restricts an application (including its preferences and data) to a unique location in the file system. This restriction is part of the security feature known as the application's "sandbox." The sandbox is a set of fine-grained controls limiting an application's access to files, preferences, network resources, hardware, and so on." The device's phone number is not available within your application's container. You will need to revise your application to read only within your directory container and resubmit your binary to iTunes Connect in order for your application to be reconsidered for the App Store.
这确实令人失望,因为我们想让用户不必输入自己的电话号码。
其他回答
不,没有合法可靠的方法来做这件事。
如果您找到了一种方法,它将在未来被禁用,就像之前的每个方法一样。
更新:该功能似乎已被苹果在iOS 4或左右删除
为了扩展之前的答案,我想说的是:
NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"];
注意:这将检索在iPhone的iTunes激活期间输入的“电话号码”,可以是null或错误的值。不是从SIM卡读取的。
至少在2.1中是这样的。在NSUserDefaults中还有其他一些有趣的键,它们可能也不会持续。(这是我的应用程序,它使用UIWebView)
WebKitJavaScriptCanOpenWindowsAutomatically
NSInterfaceStyle
TVOutStatus
WebKitDeveloperExtrasEnabledPreferenceKey
等等。
不知道其他人做了什么,如果有的话。
冒着被扣分的风险,我想建议排名最高的解决方案(目前是第一个响应)违反了2009年11月5日的最新SDK协议。我们的申请因为使用它而被拒绝了。以下是苹果公司的回应:
"For security reasons, iPhone OS restricts an application (including its preferences and data) to a unique location in the file system. This restriction is part of the security feature known as the application's "sandbox." The sandbox is a set of fine-grained controls limiting an application's access to files, preferences, network resources, hardware, and so on." The device's phone number is not available within your application's container. You will need to revise your application to read only within your directory container and resubmit your binary to iTunes Connect in order for your application to be reconsidered for the App Store.
这确实令人失望,因为我们想让用户不必输入自己的电话号码。
你可能已经知道,如果你使用下面这行代码,你的应用程序将会被苹果拒绝
NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"];
这是参考资料
http://ayeapi.blogspot.com/2009/12/sbformatphonenumber-is-lie.html
您可以使用以下信息
NSString *phoneName = [[UIDevice currentDevice] name];
NSString *phoneUniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier];
等等
@property(nonatomic,readonly,retain) NSString *name; // e.g. "My iPhone"
@property(nonatomic,readonly,retain) NSString *model; // e.g. @"iPhone", @"iPod Touch"
@property(nonatomic,readonly,retain) NSString *localizedModel; // localized version of model
@property(nonatomic,readonly,retain) NSString *systemName; // e.g. @"iPhone OS"
@property(nonatomic,readonly,retain) NSString *systemVersion; // e.g. @"2.0"
@property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation
@property(nonatomic,readonly,retain) NSString *uniqueIdentifier; // a string unique to each device based on various hardware info.
希望这能有所帮助!
使用私有API,您可以通过以下方式获取用户电话号码:
extern NSString* CTSettingCopyMyPhoneNumber();
+(NSString *) phoneNumber {
NSString *phone = CTSettingCopyMyPhoneNumber();
return phone;
}
也可以将coretphony .framework包含到你的项目中。
推荐文章
- Xcode 4 -在新的Macintosh安装上的配置文件上“没有找到有效的签名标识”错误
- 在iPhone上确定用户是否启用了推送通知
- 是否有可能禁用浮动头在UITableView与UITableViewStylePlain?
- 错误ITMS-9000:“冗余二进制文件上传。火车1.0版本已经有一个二进制版本上传。
- Swift -转换为绝对值
- 从父iOS访问容器视图控制器
- 自定义dealloc和ARC (Objective-C)
- 调整UITableView的大小以适应内容
- 在代码中为UIButton设置一个图像
- NSRange从Swift Range?
- UICollectionView中的单元格间距
- 我如何在我的iOS应用程序中每n分钟得到一个后台位置更新?
- 如何使用iOS创建GUID/UUID
- 禁用所呈现视图控制器的交互式撤销
- 点击按钮时如何打开手机设置?