当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS 隐私权限和通过openURL实现跳转实例

iOS 隐私权限和通过openURL实现跳转实例

2019年07月24日  | 移动技术网IT编程  | 我要评论

杂鱼寝,漯河黑社会王华,林庭的草药之旅

ios 10之后苹果对于用户隐私方面要求非常严格,曾经帮朋友发布纯h5的app,由于使用第三方而未加隐私权限都不让提交app store。这边就是给大家列举下苹果对于最为常见的隐私以及平时我们开发是会用到的openurl这方法所用到的key。

一、隐私权限

当然有朋友会说,不加隐私,让他奔溃后再log中找就好了,通常会导致奔溃的可以这样做,但是例如定位什么的就不会产生奔溃,直接是定位不出结果的,这时候就需要自己拼写了。

<key>nsphotolibraryusagedescription</key> 
<string>访问相册</string>

<key>nscamerausagedescription</key> 
<string>访问相机</string> 

<key>nscontactsusagedescription</key>
<string>访问通讯录</string>

<key>nsmicrophoneusagedescription</key> 
<string>访问麦克风</string> 

<key>nsapplemusicusagedescription</key> 
<string>访问媒体资料库</string>

<key>nslocationusagedescription</key> 
<string>访问位置</string> 

<key>nslocationwheninuseusagedescription</key> 
<string>使用期间访问位置</string> 

<key>nslocationalwaysusagedescription</key> 
<string>始终访问位置</string> 

<key>nscalendarsusagedescription</key> 
<string>访问日历</string> 

<key>nsremindersusagedescription</key> 
<string>访问提醒事项</string> 

<key>nsmotionusagedescription</key> 
<string>访问运动与健身</string> 

<key>nshealthupdateusagedescription</key> 
<string>访问健康更新 </string> 

<key>nshealthshareusagedescription</key> 
<string>访问健康分享</string> 

<key>nsbluetoothperipheralusagedescription</key> 
<string>访问蓝牙</string> 

<key>nssiriusagedescription</key>
<string>访问siri</string>

 
<key>nsspeechrecognitionusagedescription</key>
<string>访问语音识别</string>

以上只是列举了比较常见的。平时开发中,和手机数据交互,但代码没有问题,出现无端bug时可以考虑下是不是隐私权限问题。

二、openurl

开发中使用以下代码可以实现快速拨打电话

  nsstring* phoneversion = [[uidevice currentdevice] systemversion];
  if (phoneversion.floatvalue < 10.0) {
    //ios10 以前使用
    [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"tel://123456"]];
  }
  else {
    //ios10 以后使用
    [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"tel://123456"]
                      options:@{}
                 completionhandler:nil];
  }

只要给出对应的url,系统就可以直接跳:

//拨打电话
[nsurl urlwithstring:@"tel://123456"] 
//发送短信
[nsurl urlwithstring:@"sms://123456"]
//发邮件
[nsurl urlwithstring:@"mailto://123456@163.com"]
//前往app store
[nsurl urlwithstring:@"itms-apps://"]
//使用safari访问网址
[nsurl urlwithstring:@"http://www.baidu.com"]
//前往ibook
[nsurl urlwithstring:@"itms-books://"]
//发起facetime
[nsurl urlwithstring:@"facetime://"]
//8、调用 地图map
[nsurl urlwithstring:@"maps://"]
//9、调用 music
[nsurl urlwithstring:@"music://"]
//10、跳转到系统设置相关界面
  // ios10 以前
  [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"prefs:root=location"] options:@{} completionhandler:nil];
  // ios10 以后
  [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"app-prefs:root=location"] options:@{} completionhandler:nil];

#pragma mark - 以下为跳转设置的对应方式
//设置
[nsurl urlwithstring:uiapplicationopensettingsurlstring]

//icloud
[nsurl urlwithstring:@"app-prefs:root=castle"]

//wifi
[nsurl urlwithstring:@"app-prefs:root=wifi"]

//蓝牙
[nsurl urlwithstring:@"app-prefs:root=bluetooth"]

//蜂窝数据
[nsurl urlwithstring:@"app-prefs:root=mobile_data_settings_id"]

//通知
[nsurl urlwithstring:@"app-prefs:root=notifications_id"]

//通用
[nsurl urlwithstring:@"app-prefs:root=general"]
//关于手机
[nsurl urlwithstring:@"app-prefs:root=general&path=about"]
//辅助功能
[nsurl urlwithstring:@"app-prefs:root=general&path=accessibility"]
//日期与时间
[nsurl urlwithstring:@"app-prefs:root=general&path=date_and_time"]
//键盘设置
[nsurl urlwithstring:@"app-prefs:root=general&path=keyboard"]

//显示与亮度
[nsurl urlwithstring:@"app-prefs:root=display"]

//墙纸设置
[nsurl urlwithstring:@"app-prefs:root=wallpaper"]

//声音
[nsurl urlwithstring:@"app-prefs:root=sounds"] 

//siri
[nsurl urlwithstring:@"app-prefs:root=siri"]

//隐私
[nsurl urlwithstring:@"app-prefs:root=privacy"]
//定位
[nsurl urlwithstring:@"app-prefs:root=privacy&path=location"]

//电池电量
[nsurl urlwithstring:@"app-prefs:root=battery_usage"]

//itunes store 与 app store
[nsurl urlwithstring:@"app-prefs:root=store"]

三、总结

本文只是记录,方便以后自己查找,有遗漏的欢迎大家指出。以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网