Jump for settings above IOS 8

Source: Internet
Author: User

IOS8 above system application can interact with the settings deeply, the user can set the corresponding permission according to the needs of the app.

Most apps now still just pop up a warning window with instructions, such as "Go to Settings > Privacy > Location >app". In fact, in the higher version of the system can be directly pop up a warning window, the content is the user's own app needs permissions, click the OK button can jump directly to the settings in the app's own permissions settings interface. The specific mode of operation and code is below.

Example:

A warning code for a calendar-related application that contains the options set for the user.

  

Func Showeventsacessdeniedalert () {Let Alertcontroller = Uialertcontroller (title: "Sad face emoji!", message: "The Calendar permission is 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)}

Again, just add this code to your app to get deep links to user settings

  

If Let appSettings = Nsurl (string:uiapplicationopensettingsurlstring) {uiapplication.sharedapplication (). OpenURL ( AppSettings)}

When the user clicks on the open settings, they are very convenient to enter the interface

    

By adding these three lines of code, you can improve the user experience in an important aspect of activating app usage rights. Making it easy for users to change permissions in Settings. Again, this applies to many other applications as well.

    

Article content reference from: This article by Cocoachina translator kaming translation, original text: Ios:you ' re Doing Settings wrong.

Jump for settings above IOS 8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.