The solution for the openURL method to jump to the setting interface

The solution for the openURL method to jump to the setting interface after private iOS10

Before iOS10, the way to jump to a specified interface of the system settings interface is as follows:

//打开定位服务界面
NSURL*url=[NSURL URLWithString:@"prefs:root=Privacy&path=LOCATION"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
};

But on iOS10, when calling canOpenURL: to open the system settings interface, the console will report the following error and cannot jump:


-canOpenURL: failed for URL: "Prefs:root=Privacy&path=LOCATION" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

The reason is that iOS10 only allows the following ways to jump to the interface of your own app in the settings, and restricts jumping to other interfaces

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325671177&siteId=291194637