iOS URL设置快捷方式无法启动到设置应用程序。

huangapple go评论79阅读模式
英文:

iOS URL settings shortcut doesn't launch into settings app

问题

我想将用户引导到设置页面,并打开“未知来电静音”开关。谷歌搜索结果显示以下是用于此目的的URL:

UIApplication.shared.open(URL(string: "prefs:root=Phone&path=SILENCE_CALLS")!, options: [:])

然而,这并不起作用,它不会启动任何内容。这是否是正确的URL,或者苹果可能已禁用此功能(我正在使用iOS 16.4.1)?

英文:

(Yes I know using this url will result in Apple rejecting the app from App Store submission, however the intended use is not for an app released to the App Store).

I want to launch the user into the settings page with the silence unknown caller's switch, google results says this is the url to use for that:

UIApplication.shared.open(URL(string: "prefs:root=Phone&path=SILENCE_CALLS")!, options: [:])

However this doesn't work, it doesn't launch anything.
Is this the correct url, or might Apple have disabled this from functioning (I'm trying with iOS 16.4.1)

答案1

得分: 0

从iOS 10及更高版本开始,代码已更改,请使用以下代码。

您需要将 prefs: 更改为 App-Prefs:

UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:@"App-Prefs:root=Phone&path=SILENCE_CALLS"];
[application openURL:URL options:@{} completionHandler:^(BOOL success) {
    if (success) {
         NSLog(@"已打开URL");
    }
}];
英文:

From iOS 10+ versions code has changed, use below code.

You need to change prefs: to App-Prefs:

UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:@"App-Prefs:root=Phone&path=SILENCE_CALLS"];
[application openURL:URL options:@{} completionHandler:^(BOOL success) {
    if (success) {
         NSLog(@"Opened url");
    }
}];

huangapple
  • 本文由 发表于 2023年6月2日 00:48:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76384087.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定