iOS 开发基础IOS知识整理

iOS10 plist文件权限适配

2016-12-08  本文已影响709人  nenhall

iOS10 plist文件权限适配


//定位
<key>NSLocationUsageDescription</key>
<string>作用:App需要访问你的位置</string>

<key>NSLocationWhenInUseUsageDescription<key>
<string>作用:App在使用期间访问你的位置</string> 

<key>NSLocationAlwaysUsageDescription</key>
<string>作用:App想要始终访问你的位置</string>

Privacy - Location Usage Description
Privacy - Location When In Use Usage Description
Privacy - Location Always Usage Description

key对应的值其实就是显示在App内弹窗里面的那段文字描述,你在实际使用时,把上面的string里面的内容改成你的内容描述;

如果你使用了NSLocationAlwaysUsageDescription(App在后台定位时候还会定位), 一定要把key对应的描述写清楚,不然提交到苹果审核时,会被拒的.

在Xcode 8以后你在plist文件中输入如上key时,会自动变成以Privacy开头的key;

如你输入:NSLocationUsageDescription 会变成 Privacy - Location Usage Description 是一样的,或者你直接输入后面那key也可以


//网络请求:
//ios9后不支持http访问的解决办法:在Info.plist中添加NSAppTransportSecurity类型Dictionary。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

但是在2017.01.01开始,此方法苹果也不支持,全部走https协议,如果你还得使用http的,那得按如下配置具体到相应的域名:
这里我是直接拿QQ登陆示范的
<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>qq.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            </dict>
    </dict>

//相册
<key>NSPhotoLibraryUsageDescription</key> 
<string>App需要访问相册</string> 
//相机
<key>NSCameraUsageDescription</key>
<string>App需要访问相机</string> 
//麦克风
<key>NSMicrophoneUsageDescription</key>
<string>App需要访问麦克风</string>
//日历
<key>NSCalendarsUsageDescription</key>
<string>App需要访问日历</string> 
//提醒事项
<key>NSRemindersUsageDescription</key>
<string>App需要访问提醒事项</string>
//运动与健身
<key>NSMotionUsageDescription</key>
<string>App需要访问运动与健身</string>
//健康更新
<key>NSHealthUpdateUsageDescription</key>
<string>App需要访问健康更新 </string> 
//健康分享
<key>NSHealthShareUsageDescription</key>
<string>App需要访问健康分享</string> 
//蓝牙
<key>NSBluetoothPeripheralUsageDescription</key> 
<string>App需要访问蓝牙</string>
//语音转文字权限
<key>Privacy - Speech Recognition Usage Description</key> 
<string>是否允许此App使用语音识别</string>
//媒体资料库
<key>NSAppleMusicUsageDescription</key>
<string>App需要访问媒体资料库</string>
<key>UIBackgroundModes</key>`
<array>
//在这里写上你在后台模式下要使用权限对应的key 
<string>location</string>
...
</array>

info.plist的几个常见属性:

属性 具体作用
Localization native development region 与本地化设置有关,为默认的开发语言
Executable file 程序安装包的名称
Bundle identifier 软件唯一的标识(这不用多说吧)
InfoDictionary version 版本信息
Bundle name App安装后显示的名称
Bundle OS Type code 用来标识软件包类型
Bundle versions string, short 发布的版本字符串
Bundle creator OS Type code 创建者的标识
Bundle version 应用程序版本号(内部构建版本号)
Application requires iPhone environment 用于指示程序包是否只能运行在iPhone OS 系统上,默认为YES
Launch screen interface file base name 欢迎界面的文件名称
Main storyboard file base name 默认情况下程序的主入口
Supported interface orientations 设置程序默认支持的方向
CFBundleDisplayName 应用名称
上一篇 下一篇

猜你喜欢

热点阅读