iOS 隱私權(quán)限和通過openURL實現(xiàn)跳轉(zhuǎn)實例
iOS 10之后蘋果對于用戶隱私方面要求非常嚴(yán)格,曾經(jīng)幫朋友發(fā)布純H5的APP,由于使用第三方而未加隱私權(quán)限都不讓提交App Store。這邊就是給大家列舉下蘋果對于最為常見的隱私以及平時我們開發(fā)是會用到的openUrl這方法所用到的key。
一、隱私權(quán)限
當(dāng)然有朋友會說,不加隱私,讓他奔潰后再log中找就好了,通常會導(dǎo)致奔潰的可以這樣做,但是例如定位什么的就不會產(chǎn)生奔潰,直接是定位不出結(jié)果的,這時候就需要自己拼寫了。
<key>NSPhotoLibraryUsageDescription</key> <string>訪問相冊</string> <key>NSCameraUsageDescription</key> <string>訪問相機</string> <key>NSContactsUsageDescription</key> <string>訪問通訊錄</string> <key>NSMicrophoneUsageDescription</key> <string>訪問麥克風(fēng)</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>訪問藍(lán)牙</string> <key>NSSiriUsageDescription</key> <string>訪問Siri</string> <key>NSSpeechRecognitionUsageDescription</key> <string>訪問語音識別</string>
以上只是列舉了比較常見的。平時開發(fā)中,和手機數(shù)據(jù)交互,但代碼沒有問題,出現(xiàn)無端bug時可以考慮下是不是隱私權(quán)限問題。
二、openUrl
開發(fā)中使用以下代碼可以實現(xiàn)快速撥打電話
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]; }
只要給出對應(yīng)的URL,系統(tǒng)就可以直接跳:
//撥打電話 [NSURL URLWithString:@"tel://123456"] //發(fā)送短信 [NSURL URLWithString:@"sms://123456"] //發(fā)郵件 [NSURL URLWithString:@"mailto://123456@163.com"] //前往App Store [NSURL URLWithString:@"itms-apps://"] //使用Safari訪問網(wǎng)址 [NSURL URLWithString:@"http://www.baidu.com"] //前往iBook [NSURL URLWithString:@"itms-books://"] //發(fā)起Facetime [NSURL URLWithString:@"facetime://"] //8、調(diào)用 地圖Map [NSURL URLWithString:@"maps://"] //9、調(diào)用 Music [NSURL URLWithString:@"music://"] //10、跳轉(zhuǎn)到系統(tǒng)設(shè)置相關(guān)界面 // 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 - 以下為跳轉(zhuǎn)設(shè)置的對應(yīng)方式 //設(shè)置 [NSURL URLWithString:UIApplicationOpenSettingsURLString] //iCloud [NSURL URLWithString:@"App-Prefs:root=CASTLE"] //WIFI [NSURL URLWithString:@"App-Prefs:root=WIFI"] //藍(lán)牙 [NSURL URLWithString:@"App-Prefs:root=Bluetooth"] //蜂窩數(shù)據(jù) [NSURL URLWithString:@"App-Prefs:root=MOBILE_DATA_SETTINGS_ID"] //通知 [NSURL URLWithString:@"App-Prefs:root=NOTIFICATIONS_ID"] //通用 [NSURL URLWithString:@"App-Prefs:root=General"] //關(guān)于手機 [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"] //鍵盤設(shè)置 [NSURL URLWithString:@"App-Prefs:root=General&path=Keyboard"] //顯示與亮度 [NSURL URLWithString:@"App-Prefs:root=DISPLAY"] //墻紙設(shè)置 [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"]
三、總結(jié)
本文只是記錄,方便以后自己查找,有遺漏的歡迎大家指出。以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS App開發(fā)中UISearchBar搜索欄組件的基本用法整理
iOS開發(fā)組件中自帶的UISearchBar提供了很多基礎(chǔ)和好用的搜索欄UI功能,下面就來總結(jié)一下iOS App開發(fā)中UISearchBar搜索欄組件的基本用法整理,需要的朋友可以參考下2016-05-05iOS遍歷集合(NSArray、NSDictionary、NSSet)的方法總結(jié)
這篇文章主要介紹了iOS集合遍歷(NSArray、NSDictionary、NSSet)的方法,文中給出了詳細(xì)的方法示例,并總結(jié)了各個方法的優(yōu)缺點來供大家學(xué)習(xí)參考,需要的朋友們下面來一起看看吧。2017-03-03你應(yīng)該知道的tableViewCell行高計算處理
這篇文章主要給大家介紹了關(guān)于tableViewCell行高計算的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-12-12