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