iOS 8以上的設定的跳轉

來源:互聯網
上載者:User

標籤:

  iOS8以上的系統應用可以與設定進行深層的互動,使用者可以根據APP的需要進行對應的許可權的設定。

  現在大多數的APP依舊僅僅是彈出一個包含操作指令的警示視窗,如“進入設定>隱私>位置>APP”。其實在高版本的系統中可以直接彈出一個警示視窗,提示內容是自己的APP需要的許可權,點擊確定按鈕可以直接跳到設定中的APP本身的使用權限設定介面。具體的操作方式及代碼在下面。

  舉例:

  一下是一個日曆相關應用程式的警告代碼,其中包含了為使用者佈建的選項。

  

func showEventsAcessDeniedAlert() {let alertController = UIAlertController(title: "Sad Face Emoji!",message: "The calendar permission was not authorized. Please enable it in Settings to continue.",preferredStyle: .Alert)let settingsAction = UIAlertAction(title: "Settings", style: .Default) { (alertAction) in// THIS IS WHERE THE MAGIC HAPPENS!!!!if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) {UIApplication.sharedApplication().openURL(appSettings)}}alertController.addAction(settingsAction)let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)alertController.addAction(cancelAction)presentViewController(alertController, animated: true, completion: nil)}

  再次提醒,僅需要添加此代碼到您的APP中就能實現與使用者佈建進行深層連結

  

if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) {UIApplication.sharedApplication().openURL(appSettings)}

  當使用者點擊開啟設定的時候,他們就很方便的進入了這個介面

    

    只需添加這三行代碼,就能在啟用APP使用許可權這一重要方面提高使用者體驗。讓使用者更改設定中的許可權變得簡單易行。同樣,這也適用於許多其他的應用程式。

    

  文章內容參考自:本文由CocoaChina譯者Kaming翻譯,原文:iOS: You’re Doing Settings Wrong。

iOS 8以上的設定的跳轉

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.