英文:
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");
}
}];
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论