Settings for the app

Source: Internet
Author: User

One of the most unknown features of IOS 8 and later is a deep link to app settings that allows users to authorize settings such as location, notifications, contacts, cameras, calendars, and health, depending on the app's needs.

Most applications simply pop up a warning window with instructions, such as "Go to Settings > Privacy > Location >our_app". For example, Twitter's application has a more refined and friendly indicator dialog, so I'll use it as an example.

Hopefully more iOS developers will be able to set up direct deep links with user settings, especially when it's easy to operate.

The following is a warning reminder code for a calendar-related application that contains the options for setting up a user. I'm trying to include an option to bring the user into the settings.

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" , Span class= "crayon-v" >style: . Cancel, handler: Span class= "crayon-v" >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 rejects the authorization, this is more like the swarm application.

When the user clicks on "Open settings", they are able to easily access the interface.

By adding these three lines of code, you can improve the user experience in an important aspect of activating app usage rights. In my case, the user may not be able to continue using the application because the calendar is not authorized. Therefore, my greatest interest is to make it easy for users to change permissions in Settings. Again, this applies to many other applications as well.

Settings for the app

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.