从另一个应用程序打开“设置”应用程序

发布于 2024-11-01 03:29:32 字数 242 浏览 5 评论 0原文

好吧,我知道有很多关于它的问题,但它们都是很久以前的事了。

所以。我知道这是可能的,因为地图应用程序可以做到这一点。

在地图应用程序中,如果我关闭该应用程序的本地化,它会向我发送一条消息,如果我按“确定”,“设置应用程序”将打开。 我的问题是,这怎么可能? 如何从我自己的应用程序中打开“设置应用程序”?

基本上我需要做同样的事情,如果用户关闭我的应用程序的位置,那么我会向他显示一条消息,说明将打开“设置应用程序”的内容

Okay, I know that there are many question about it, but they are all from many time ago.

So. I know that it is possible because the Map app does it.

In the Map app if I turn off the localization for this app, it send me a message, and if I press okay, the "Settings App" will be open.
And my question is, how is this possible?
How can I open the "Setting app" from my own app?

Basically I need to do the same thing, if the user turn off the location for my app, then I'll show him a message saying something that will open the "Setting app"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(19

路还长,别太狂 2024-11-08 03:29:32

正如Karan Dua所述,这是现在可以在 iOS8 中使用 UIApplicationOpenSettingsURLString 请参阅 Apple 文档

示例:

Swift 4.2

UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)

在 Swift 3 中:

UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!)

在 Swift 2 中:

UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)

在 Objective-C 中 >

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

iOS 8 之前:

不能。正如您所说,这已经被多次提及,并且弹出窗口要求您打开位置服务是由 Apple 提供的,而不是由应用程序本身提供的。这就是为什么它能够打开设置应用程序。

以下是一些相关问题&文章:

是否可以使用 openURL 打开设置应用程序?

以编程方式打开设置应用 (iPhone)

当用户按下 a 时如何打开“设置”应用按钮?

iPhone:从应用程序打开应用程序首选项面板

通过单击应用程序首选项中的条目 - 如何操作?

打开“设置”应用程序?

iOS:您的设置错误

As mentioned by Karan Dua this is now possible in iOS8 using UIApplicationOpenSettingsURLString see Apple's Documentation.

Example:

Swift 4.2

UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)

In Swift 3:

UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!)

In Swift 2:

UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)

In Objective-C

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

Prior to iOS 8:

You can not. As you said this has been covered many times and that pop up asking you to turn on location services is supplied by Apple and not by the App itself. That is why it is able to the open the settings application.

Here are a few related questions & articles:

is it possible to open Settings App using openURL?

Programmatically opening the settings app (iPhone)

How can I open the Settings app when the user presses a button?

iPhone: Opening Application Preferences Panel From App

Open UIPickerView by clicking on an entry in the app's preferences - How to?

Open the Settings app?

iOS: You’re Doing Settings Wrong

我ぃ本無心為│何有愛 2024-11-08 03:29:32

来自@Yatheeshaless答案

您可以在 iOS8 中以编程方式打开设置应用程序,但在早期版本的 iOS 中则不能。

Swift:

   UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)

Swift 4:

if let url = NSURL(string: UIApplicationOpenSettingsURLString) as URL? {
    UIApplication.shared.openURL(url)
}

Swift 4.2(测试版):

if let url = NSURL(string: UIApplication.openSettingsURLString) as URL? {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

Objective-C:

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

From @Yatheeshaless's answer:

You can open settings app programmatically in iOS8, but not in earlier versions of iOS.

Swift:

   UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)

Swift 4:

if let url = NSURL(string: UIApplicationOpenSettingsURLString) as URL? {
    UIApplication.shared.openURL(url)
}

Swift 4.2 (BETA):

if let url = NSURL(string: UIApplication.openSettingsURLString) as URL? {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

Objective-C:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
谜兔 2024-11-08 03:29:32

是!!您可以启动“设备设置”屏幕,我已经在 iOS 9.2 上进行了测试

第 1 步。我们需要添加 URL 方案

转到项目设置-->信息--> URL 类型 -->添加新的 URL 方案

在此处输入图像描述

第 2 步。 以编程方式启动设置 感谢 @davidcann< /a>

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

此外,我们还可以通过使用正确的名称来启动音乐、位置等子屏幕。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=MUSIC"]];

请参阅此完整名称列表此处 由 Henri Normak 分享


更新:

根据评论,每个人都想知道会发生什么在我的申请提交状态发生此更改之后?

所以是!!我成功提交了更新,并且应用程序可以在商店中使用,没有任何抱怨。

只是确认一下,
我今天早上刚刚下载并禁用了位置服务,然后启动了该应用程序,它要求我提供位置许可,然后我的警报弹出窗口向我发送设置 -> 。位置服务页面-->已启用-->就是这样!!

![注意:
您的应用程序可能会被拒绝...即使已获得批准,如果您使用此方法,在未来版本中也可能会被拒绝...]
4

YES!! you can launch Device Settings screen, I have tested on iOS 9.2

Step 1. we need to add URL schemes

Go to Project settings --> Info --> URL Types --> Add New URL Schemes

enter image description here

Step 2. Launch Settings programmatically Thanks to @davidcann

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

Also we can launch sub-screens like Music, Location etc. as well by just using proper name

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=MUSIC"]];

See this full name list here shared by Henri Normak


Update:

As per the comment everyone wants to know what happens after this change to my application submission status?

So YES!! I got successful update submission and application is available on store without any complain.

Just to confirm,
I Just downloaded this morning and disabled Location services, and then started the app, which asked me for location permission and then my alert popup was there to send me on settings -> location services page --> Enabled --> That's it!!

![NOTICE:
Your app might be rejected ... even if it's approved it can be rejected in future version if you use this method...]
4

德意的啸 2024-11-08 03:29:32

似乎您可以使用 prefs:

URL 打开设置并转到特定区域。 Apple 可能会更改这些内容并破坏您的应用程序,因此请务必先检查您是否可以打开它们。

从这个 文章 他们列出了 iOS 13.1 的其中一些:

设置 URL

iCloud

  • iCloud:prefs:root=CASTLE
  • iCloud 备份:prefs:root=CASTLE&path=BACKUP

无线无线电

  • Wi-Fi:prefs:root=WIFI
  • 蓝牙:prefs:root=Bluetooth
  • 蜂窝网络:prefs:root=MOBILE_DATA_SETTINGS_ID

  • 个人热点 个人热点:prefs:root=INTERNET_TETHERING
  • 个人热点⇾ 家庭共享:prefs:root=INTERNET_TETHERING&path=Family%20Sharing
  • 个人热点 ⇾ Wi-Fi 密码:prefs:root=INTERNET_TETHERING&path=Wi-Fi%20Password

VPN

  • VPN:prefs:root=General&path=VPN

通知

  • 通知:prefs:root=NOTIFICATIONS_ID
  • 通知 ⇾ Siri 建议:prefs:root=NOTIFICATIONS_ID&path=Siri%20Suggestions

声音

  • 声音:prefs:root=Sounds
  • 铃声:prefs: root=Sounds&path=Ringtone

请勿打扰

  • 请勿打扰: prefs:root=DO_NOT_DISTURB
  • 请勿打扰 ⇾ 允许来自以下位置的呼叫: prefs: root=DO_NOT_DISTURB&path=Allow%20Calls%20From

屏幕时间

  • 屏幕时间:prefs:root=SCREEN_TIME
  • 屏幕时间 ⇾ 停机时间:prefs:root =SCREEN_TIME&path=DOWNTIME
  • 屏幕时间 ⇾ 应用程序限制:prefs:root=SCREEN_TIME&path=APP_LIMITS
  • 屏幕时间 ⇾ 始终允许:prefs:root=SCREEN_TIME&path=ALWAYS_ALLOWED

常规

  • 常规:prefs:root=General
  • 常规⇾关于:prefs:root=General&path=About
  • 常规⇾软件更新: prefs:root=General&path=SOFTWARE_UPDATE_LINK
  • 常规 ⇾ CarPlay:prefs:root=General&path=CARPLAY
  • 常规 ⇾ 后台应用程序刷新:prefs:root= General&path=AUTO_CONTENT_DOWNLOAD
  • General ⇾ 多任务处理(仅限 iPad): prefs:root=General&path=MULTITASKING
  • General ⇾ 日期和时间时间:prefs:root=General&path=DATE_AND_TIME
  • 常规 ⇾ 键盘:prefs:root=General&path=Keyboard
  • 常规 ⇾ 键盘 ⇾ 键盘:prefs:root =General&path=Keyboard/KEYBOARDS
  • 常规 ⇾ 键盘 ⇾ 硬件键盘: prefs:root=General&path=Keyboard/Hardware%20Keyboard
  • 常规 ⇾ 键盘 ⇾ 文本替换: prefs :root=General&path=Keyboard/USER_DICTIONARY
  • 常规 ⇾ 键盘 ⇾ 单手键盘: prefs:root=General&path=Keyboard/ReachableKeyboard
  • 常规 ⇾ 语言和语言区域:prefs:root=General&path=INTERNATIONAL
  • 常规 ⇾ 词典:prefs:root=General&path=DICTIONARY
  • 常规 ⇾ 配置文件:prefs:root=General& ;path=ManagedConfigurationList
  • 常规 ⇾ 重置:prefs:root=General&path=Reset

控制中心

  • 控制中心:prefs:root=ControlCenter
  • 控制中心 ⇾ 自定义控件:prefs:root=ControlCenter&path=CUSTOMIZE_CONTROLS

显示

  • 显示:prefs:root=DISPLAY
  • 显示 ⇾ 自动锁定: prefs:root=DISPLAY&path=AUTOLOCK
  • 显示 ⇾ 文本大小:prefs:root=DISPLAY&path=TEXT_SIZE

辅助功能

  • 辅助功能:>prefs:root=ACCESSIBILITY

壁纸

  • 壁纸:prefs:root=Wallpaper

Siri

  • Siri:prefs:root=SIRI

Apple Pencil

  • Apple Pencil(仅限 iPad):prefs:root=Pencil

Face ID

  • Face ID:prefs: root=PASSCODE

紧急求救

  • 紧急求救:prefs:root=EMERGENCY_SOS

电池

  • 电池:prefs:root=BATTERY_USAGE< /code>
  • 电池 ⇾ 电池健康状况(仅限 iPhone):prefs:root=BATTERY_USAGE&path=BATTERY_HEALTH

隐私

  • 隐私:prefs:root=Privacy
  • 隐私 ⇾ 位置服务:prefs:root=Privacy&path=LOCATION
  • 隐私 ⇾ 联系人:prefs:root=Privacy&path=CONTACTS
  • 隐私 ⇾ 日历:prefs :root=Privacy&path=CALENDARS
  • 隐私 ⇾ 提醒:prefs:root=Privacy&path=REMINDERS
  • 隐私 ⇾ 照片:prefs:root=Privacy&path=PHOTOS code>
  • 隐私 ⇾ 麦克风:prefs:root=Privacy&path=MICROPHONE
  • 隐私 ⇾ 语音识别:prefs:root=Privacy&path=SPEECH_RECOGNITION
  • 隐私 ⇾ 摄像头:prefs:root=Privacy&path=CAMERA
  • 隐私 ⇾ Motion:prefs:root=Privacy&path=MOTION\

App Store

  • App Store:prefs :root=STORE
  • App Store ⇾ 应用程序下载:prefs:root=STORE&path=App%20Downloads
  • App Store ⇾ 视频自动播放:prefs:root=STORE&path=Video %20Autoplay

钱包

  • 钱包:prefs:root=PASSBOOK

密码和密码帐户

  • 和密码帐户: prefs:root=ACCOUNTS_AND_PASSWORDS
  • 密码和密码帐户 ⇾ 获取新数据:prefs:root=ACCOUNTS_AND_PASSWORDS&path=FETCH_NEW_DATA
  • 密码和密码帐户 ⇾ 添加帐户:prefs:root=ACCOUNTS_AND_PASSWORDS&path=ADD_ACCOUNT

邮件

  • 邮件:prefs:root=MAIL
  • 邮件 ⇾ 预览:prefs:root=MAIL&path=Preview
  • 邮件 ⇾ 滑动选项:prefs:root=MAIL&path=Swipe%20Options
  • 邮件 ⇾ 通知:prefs:root=MAIL&path =通知
  • 邮件⇾被阻止:prefs:root=MAIL&path=Blocked
  • 邮件⇾静音线程操作:prefs:root=MAIL&path=Mulated%20Thread%20Action code>
  • 邮件 ⇾ 阻止发件人选项:prefs:root=MAIL&path=Blocked%20Sender%20Options
  • 邮件 ⇾ 标记地址:prefs:root=MAIL&path=Mark%20Addresses >
  • 邮件 ⇾ 提高报价级别:prefs:root=MAIL&path=Increase%20Quote%20Level
  • 邮件 ⇾ 在回复中包含附件:prefs:root=MAIL&path=Include%20Attachments%20with %20Replies
  • 邮件 ⇾ 签名:prefs:root=MAIL&path=Signature
  • 邮件 ⇾ 默认帐户:prefs:root=MAIL&path=Default%20Account

< strong>联系人

  • 联系人:prefs:root=CONTACTS

日历

  • 日历:prefs:root=CALENDAR
  • 日历 ⇾ 备用日历:>prefs:root=CALENDAR&path=Alternate%20Calendars
  • 日历 ⇾ 同步:prefs:root=CALENDAR&path=Sync
  • 日历 ⇾ 默认提醒时间:prefs:root=CALENDAR& ;path=Default%20Alert%20Times
  • 日历 ⇾ 默认日历: prefs:root=CALENDAR&path=Default%20Calendar

注释

  • 注释: prefs: root=NOTES
  • 备注 ⇾ 默认帐户:prefs:root=NOTES&path=Default%20Account
  • 备注 ⇾ 密码:prefs:root=NOTES&path=Password
  • 笔记 ⇾ 笔记排序方式:prefs:root=NOTES&path=Sort%20Notes%20By
  • 笔记 ⇾ 新笔记开头:prefs:root=NOTES&path=New%20Notes%20Start% 20With
  • 注释 ⇾ 对选中的项目进行排序: prefs:root=NOTES&path=Sort%20Checked%20Items
  • 注释 ⇾ 行和行网格:prefs:root=NOTES&path=Lines%20%26%20Grids
  • 笔记 ⇾ 从锁定屏幕访问笔记:prefs:root=NOTES&path=Access%20Notes%20from%20Lock %20Screen

提醒

  • 提醒:prefs:root=REMINDERS
  • 提醒 ⇾ 默认列表:prefs:root=REMINDERS&path=DEFAULT_LIST

< strong>语音备忘录

  • 语音备忘录:prefs:root=VOICE_MEMOS

电话

  • 电话:prefs:root=Phone

消息< /strong>

  • 消息:prefs:root=MESSAGES

FaceTime

  • FaceTime:prefs:root=FACETIME

地图

  • 地图:< code>prefs:root=MAPS
  • 地图 ⇾ 驾驶和驾驶导航:prefs:root=MAPS&path=Driving%20%26%20Navigation
  • 地图 ⇾ 公交:prefs:root=MAPS&path=Transit

指南针 strong>

  • 指南针:prefs:root=COMPASS

测量

  • 测量:prefs:root=MEASURE

Safari

  • Safari:prefs:root=SAFARI
  • Safari ⇾ 内容拦截器:prefs:root=SAFARI&path=Content%20Blockers
  • Safari ⇾ 下载:prefs:root=SAFARI&path=DOWNLOADS< /code>
  • Safari ⇾ 关闭标签页:prefs:root=SAFARI&path=Close%20Tabs
  • Safari ⇾ 清除历史记录和数据:prefs:root=SAFARI&path=CLEAR_HISTORY_AND_DATA
  • Safari ⇾ 页面缩放:prefs:root=SAFARI&path=Page%20Zoom
  • Safari ⇾ 请求桌面网站:prefs:root=SAFARI&path=Request%20Desktop%20Website
  • Safari ⇾阅读器:prefs:root=SAFARI&path=Reader
  • Safari ⇾ 摄像头:prefs:root=SAFARI&path=Camera
  • Safari ⇾ 麦克风:prefs:root=SAFARI& ;path=麦克风
  • Safari ⇾ 位置:prefs:root=SAFARI&path=Location
  • Safari ⇾ 高级:prefs:root=SAFARI&path=ADVANCED

新闻

  • 新闻:prefs:root=NEWS

健康

  • 健康:prefs:root=HEALTH

快捷方式

  • 快捷方式: prefs:root=SHORTCUTS

音乐

  • 音乐:
  • prefs:root=MUSIC 音乐 ⇾ 蜂窝数据: prefs:root=MUSIC& path=com.apple.Music:CellularData
  • 音乐 ⇾ 优化存储:prefs:root=MUSIC&path=com.apple.Music:OptimizeStorage
  • 音乐 ⇾ EQ:prefs:root =MUSIC&path=com.apple.Music:EQ
  • 音乐 ⇾ 音量限制:prefs:root=MUSIC&path=com.apple.Music:VolumeLimit

电视

  • 设置 ⇾ 电视:prefs:root=TVAPP

照片

  • 照片:prefs:root=Photos

相机

  • 相机:< code>prefs:root=CAMERA
  • 相机 ⇾ 录制视频:prefs:root=CAMERA&path=Record%20Video
  • 相机 ⇾ 录制慢动作:prefs:root=CAMERA& path=Record%20Slo-mo

书籍

  • 书籍:prefs:root=IBOOKS

游戏中心

  • 游戏中心:偏好: root=GAMECENTER

Seems like you can use the prefs:<area> URL to open the settings and go to specific areas. Apple could change these and break your app so always check if you can open them first.

From this article they have listed some of them for iOS 13.1:

Settings URLs

iCloud

  • iCloud: prefs:root=CASTLE
  • iCloud Backup: prefs:root=CASTLE&path=BACKUP

Wireless Radios

  • Wi-Fi: prefs:root=WIFI
  • Bluetooth: prefs:root=Bluetooth
  • Cellular: prefs:root=MOBILE_DATA_SETTINGS_ID

Personal Hotspot

  • Personal Hotspot: prefs:root=INTERNET_TETHERING
  • Personal Hotspot ⇾ Family Sharing: prefs:root=INTERNET_TETHERING&path=Family%20Sharing
  • Personal Hotspot ⇾ Wi-Fi Password: prefs:root=INTERNET_TETHERING&path=Wi-Fi%20Password

VPN

  • VPN: prefs:root=General&path=VPN

Notifications

  • Notifications: prefs:root=NOTIFICATIONS_ID
  • Notifications ⇾ Siri Suggestions: prefs:root=NOTIFICATIONS_ID&path=Siri%20Suggestions

Sounds

  • Sounds: prefs:root=Sounds
  • Ringtone: prefs:root=Sounds&path=Ringtone

Do Not Disturb

  • Do Not Disturb: prefs:root=DO_NOT_DISTURB
  • Do Not Disturb ⇾ Allow Calls From: prefs:root=DO_NOT_DISTURB&path=Allow%20Calls%20From

Screen Time

  • Screen Time: prefs:root=SCREEN_TIME
  • Screen Time ⇾ Downtime: prefs:root=SCREEN_TIME&path=DOWNTIME
  • Screen Time ⇾ App Limits: prefs:root=SCREEN_TIME&path=APP_LIMITS
  • Screen Time ⇾ Always Allowed: prefs:root=SCREEN_TIME&path=ALWAYS_ALLOWED

General

  • General: prefs:root=General
  • General ⇾ About: prefs:root=General&path=About
  • General ⇾ Software Update: prefs:root=General&path=SOFTWARE_UPDATE_LINK
  • General ⇾ CarPlay: prefs:root=General&path=CARPLAY
  • General ⇾ Background App Refresh: prefs:root=General&path=AUTO_CONTENT_DOWNLOAD
  • General ⇾ Multitasking (iPad-only): prefs:root=General&path=MULTITASKING
  • General ⇾ Date & Time: prefs:root=General&path=DATE_AND_TIME
  • General ⇾ Keyboard: prefs:root=General&path=Keyboard
  • General ⇾ Keyboard ⇾ Keyboards: prefs:root=General&path=Keyboard/KEYBOARDS
  • General ⇾ Keyboard ⇾ Hardware Keyboard: prefs:root=General&path=Keyboard/Hardware%20Keyboard
  • General ⇾ Keyboard ⇾ Text Replacement: prefs:root=General&path=Keyboard/USER_DICTIONARY
  • General ⇾ Keyboard ⇾ One Handed Keyboard: prefs:root=General&path=Keyboard/ReachableKeyboard
  • General ⇾ Language & Region: prefs:root=General&path=INTERNATIONAL
  • General ⇾ Dictionary: prefs:root=General&path=DICTIONARY
  • General ⇾ Profiles: prefs:root=General&path=ManagedConfigurationList
  • General ⇾ Reset: prefs:root=General&path=Reset

Control Center

  • Control Center: prefs:root=ControlCenter
  • Control Center ⇾ Customize Controls: prefs:root=ControlCenter&path=CUSTOMIZE_CONTROLS

Display

  • Display: prefs:root=DISPLAY
  • Display ⇾ Auto Lock: prefs:root=DISPLAY&path=AUTOLOCK
  • Display ⇾ Text Size: prefs:root=DISPLAY&path=TEXT_SIZE

Accessibility

  • Accessibility: prefs:root=ACCESSIBILITY

Wallpaper

  • Wallpaper: prefs:root=Wallpaper

Siri

  • Siri: prefs:root=SIRI

Apple Pencil

  • Apple Pencil (iPad-only): prefs:root=Pencil

Face ID

  • Face ID: prefs:root=PASSCODE

Emergency SOS

  • Emergency SOS: prefs:root=EMERGENCY_SOS

Battery

  • Battery: prefs:root=BATTERY_USAGE
  • Battery ⇾ Battery Health (iPhone-only): prefs:root=BATTERY_USAGE&path=BATTERY_HEALTH

Privacy

  • Privacy: prefs:root=Privacy
  • Privacy ⇾ Location Services: prefs:root=Privacy&path=LOCATION
  • Privacy ⇾ Contacts: prefs:root=Privacy&path=CONTACTS
  • Privacy ⇾ Calendars: prefs:root=Privacy&path=CALENDARS
  • Privacy ⇾ Reminders: prefs:root=Privacy&path=REMINDERS
  • Privacy ⇾ Photos: prefs:root=Privacy&path=PHOTOS
  • Privacy ⇾ Microphone: prefs:root=Privacy&path=MICROPHONE
  • Privacy ⇾ Speech Recognition: prefs:root=Privacy&path=SPEECH_RECOGNITION
  • Privacy ⇾ Camera: prefs:root=Privacy&path=CAMERA
  • Privacy ⇾ Motion: prefs:root=Privacy&path=MOTION\

App Store

  • App Store: prefs:root=STORE
  • App Store ⇾ App Downloads: prefs:root=STORE&path=App%20Downloads
  • App Store ⇾ Video Autoplay: prefs:root=STORE&path=Video%20Autoplay

Wallet

  • Wallet: prefs:root=PASSBOOK

Passwords & Accounts

  • Passwords & Accounts: prefs:root=ACCOUNTS_AND_PASSWORDS
  • Passwords & Accounts ⇾ Fetch New Data: prefs:root=ACCOUNTS_AND_PASSWORDS&path=FETCH_NEW_DATA
  • Passwords & Accounts ⇾ Add Account: prefs:root=ACCOUNTS_AND_PASSWORDS&path=ADD_ACCOUNT

Mail

  • Mail: prefs:root=MAIL
  • Mail ⇾ Preview: prefs:root=MAIL&path=Preview
  • Mail ⇾ Swipe Options: prefs:root=MAIL&path=Swipe%20Options
  • Mail ⇾ Notifications: prefs:root=MAIL&path=NOTIFICATIONS
  • Mail ⇾ Blocked: prefs:root=MAIL&path=Blocked
  • Mail ⇾ Muted Thread Action: prefs:root=MAIL&path=Muted%20Thread%20Action
  • Mail ⇾ Blocked Sender Options: prefs:root=MAIL&path=Blocked%20Sender%20Options
  • Mail ⇾ Mark Addresses: prefs:root=MAIL&path=Mark%20Addresses
  • Mail ⇾ Increase Quote Level: prefs:root=MAIL&path=Increase%20Quote%20Level
  • Mail ⇾ Include Attachments with Replies: prefs:root=MAIL&path=Include%20Attachments%20with%20Replies
  • Mail ⇾ Signature: prefs:root=MAIL&path=Signature
  • Mail ⇾ Default Account: prefs:root=MAIL&path=Default%20Account

Contacts

  • Contacts: prefs:root=CONTACTS

Calendar

  • Calendar: prefs:root=CALENDAR
  • Calendar ⇾ Alternate Calendars: prefs:root=CALENDAR&path=Alternate%20Calendars
  • Calendar ⇾ Sync: prefs:root=CALENDAR&path=Sync
  • Calendar ⇾ Default Alert Times: prefs:root=CALENDAR&path=Default%20Alert%20Times
  • Calendar ⇾ Default Calendar: prefs:root=CALENDAR&path=Default%20Calendar

Notes

  • Notes: prefs:root=NOTES
  • Notes ⇾ Default Account: prefs:root=NOTES&path=Default%20Account
  • Notes ⇾ Password: prefs:root=NOTES&path=Password
  • Notes ⇾ Sort Notes By: prefs:root=NOTES&path=Sort%20Notes%20By
  • Notes ⇾ New Notes Start With: prefs:root=NOTES&path=New%20Notes%20Start%20With
  • Notes ⇾ Sort Checked Items: prefs:root=NOTES&path=Sort%20Checked%20Items
  • Notes ⇾ Lines & Grids: prefs:root=NOTES&path=Lines%20%26%20Grids
  • Notes ⇾ Access Notes from Lock Screen: prefs:root=NOTES&path=Access%20Notes%20from%20Lock%20Screen

Reminders

  • Reminders: prefs:root=REMINDERS
  • Reminders ⇾ Default List: prefs:root=REMINDERS&path=DEFAULT_LIST

Voice Memos

  • Voice Memos: prefs:root=VOICE_MEMOS

Phone

  • Phone: prefs:root=Phone

Messages

  • Messages: prefs:root=MESSAGES

FaceTime

  • FaceTime: prefs:root=FACETIME

Maps

  • Maps: prefs:root=MAPS
  • Maps ⇾ Driving & Navigation: prefs:root=MAPS&path=Driving%20%26%20Navigation
  • Maps ⇾ Transit: prefs:root=MAPS&path=Transit

Compass

  • Compass: prefs:root=COMPASS

Measure

  • Measure: prefs:root=MEASURE

Safari

  • Safari: prefs:root=SAFARI
  • Safari ⇾ Content Blockers: prefs:root=SAFARI&path=Content%20Blockers
  • Safari ⇾ Downloads: prefs:root=SAFARI&path=DOWNLOADS
  • Safari ⇾ Close Tabs: prefs:root=SAFARI&path=Close%20Tabs
  • Safari ⇾ Clear History and Data: prefs:root=SAFARI&path=CLEAR_HISTORY_AND_DATA
  • Safari ⇾ Page Zoom: prefs:root=SAFARI&path=Page%20Zoom
  • Safari ⇾ Request Desktop Website: prefs:root=SAFARI&path=Request%20Desktop%20Website
  • Safari ⇾ Reader: prefs:root=SAFARI&path=Reader
  • Safari ⇾ Camera: prefs:root=SAFARI&path=Camera
  • Safari ⇾ Microphone: prefs:root=SAFARI&path=Microphone
  • Safari ⇾ Location: prefs:root=SAFARI&path=Location
  • Safari ⇾ Advanced: prefs:root=SAFARI&path=ADVANCED

News

  • News: prefs:root=NEWS

Health

  • Health: prefs:root=HEALTH

Shortcuts

  • Shortcuts: prefs:root=SHORTCUTS

Music

  • Music: prefs:root=MUSIC
  • Music ⇾ Cellular Data: prefs:root=MUSIC&path=com.apple.Music:CellularData
  • Music ⇾ Optimize Storage: prefs:root=MUSIC&path=com.apple.Music:OptimizeStorage
  • Music ⇾ EQ: prefs:root=MUSIC&path=com.apple.Music:EQ
  • Music ⇾ Volume Limit: prefs:root=MUSIC&path=com.apple.Music:VolumeLimit

TV

  • Settings ⇾ TV: prefs:root=TVAPP

Photos

  • Photos: prefs:root=Photos

Camera

  • Camera: prefs:root=CAMERA
  • Camera ⇾ Record Video: prefs:root=CAMERA&path=Record%20Video
  • Camera ⇾ Record Slo-mo: prefs:root=CAMERA&path=Record%20Slo-mo

Books

  • Books: prefs:root=IBOOKS

Game Center

  • Game Center: prefs:root=GAMECENTER
汹涌人海 2024-11-08 03:29:32

您可以在 iOS 5.0 及更高版本上使用此功能: 这不再有效。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

You can use this on iOS 5.0 and later: This no longer works.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];
春庭雪 2024-11-08 03:29:32

iOS 10更新

Apple更改了在主线程上打开异步的方法。但是,从现在开始,只能在本机设置中打开应用程序设置。

[[UIApplication sharedApplication] openURL:url options:@{}completionHandler:nil];

iOS 9 更新

现在可以直接进入子设置菜单。但是,必须创建 URL 方案。可以使用两种方式完成:

  1. XCode - 您可以在 Target、Info、URL Scheme 中找到它。然后,只需输入首选项。
  2. 直接添加到*-Info.plist。添加以下内容:
    CFBundleURLTypes
    <数组>
    <字典>
    <键>CFBundleTypeRole
    <字符串>编辑器
    <键>CFBundleURLSchemes
    <数组>
    <字符串>首选项



然后代码:

Swift

UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=General&path=Keyboard")!)

Objective-c

[[ UIApplication shareApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Keyboard"]];

iOS 10 update

Apple changed the method to open async on the main thread. However, from now it is only possible to open the app settings in native settings.

[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];

iOS 9 update

It is now possible to go directly to sub-settings menu. However, a URL scheme has to be created. It can be done using two ways:

  1. XCode - You will find it in Target, Info, URL Scheme. Then, just type prefs.
  2. Directly adding to *-Info.plist. Add the following:
    <key>CFBundleURLTypes</key>
    <array>
    <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
    <string>prefs</string>
    </array>
    </dict>
    </array>

Then the code:

Swift

UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=General&path=Keyboard")!)

Objective-c

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Keyboard"]];

两仪 2024-11-08 03:29:32

在 Swift 3 / iOS 10+ 中,现在看起来像

if let url = URL(string: "App-Prefs:root=LOCATION_SERVICES") {
    UIApplication.shared.open(url, completionHandler: .none)
}

In Swift 3 / iOS 10+ this now looks like

if let url = URL(string: "App-Prefs:root=LOCATION_SERVICES") {
    UIApplication.shared.open(url, completionHandler: .none)
}
梦明 2024-11-08 03:29:32

在 Swift 3 中,我需要的就是这个(例如,重定向到我的应用程序通知):

if let url = URL(string: "App-Prefs:root=NOTIFICATIONS_ID&path=your app bundleID") {
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(url, completionHandler: .none)
    } else {
        // Fallback on earlier versions
    }
}

来源:phynet gist。

仅当设置在后台时,这才对我有用。它会将您重定向到应用程序通知设置,但如果设置没有在后台运行,它只会将您重定向到一般通知设置。

In Swift 3 all I needed is this (here for example redirect to my app notifications):

if let url = URL(string: "App-Prefs:root=NOTIFICATIONS_ID&path=your app bundleID") {
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(url, completionHandler: .none)
    } else {
        // Fallback on earlier versions
    }
}

Source: phynet gist.

This worked with me only when settings is in background. It will redirect you to your app notification settings but if settings wasn't running in the background it will just redirect you to notification settings in general.

陈独秀 2024-11-08 03:29:32

斯威夫特3:

guard let url = URL(string: UIApplicationOpenSettingsURLString) else {return}
if #available(iOS 10.0, *) {
  UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
  // Fallback on earlier versions
  UIApplication.shared.openURL(url)
}

Swift 3:

guard let url = URL(string: UIApplicationOpenSettingsURLString) else {return}
if #available(iOS 10.0, *) {
  UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
  // Fallback on earlier versions
  UIApplication.shared.openURL(url)
}
吖咩 2024-11-08 03:29:32

UIApplicationOpenSettingsURLString 仅当您之前允许任何权限时,此操作才会起作用。例如位置、照片、联系人、推送通知访问。因此,如果您没有获得用户的此类权限:

如果是iOS 10 或更高版本

它将打开“设置”,但随后会崩溃。原因是,您的应用程序的设置中没有任何内容。

下面的代码将在 iOS 设置中打开您的应用程序设置。

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
}

由于设备不可用,我无法在 iOS 上检查此内容 < 10.

另外,我可以从一些要点中找到下面的代码,它在 iOS 10 上也能正常工作。但我不确定这是否会得到苹果审核团队的批准。

UIApplicationOpenSettingsURLString this will only work if you have previously allowed for any permission. For example Location, Photo, Contact, Push notification access. So if you have not such permission(s) from the user:

If iOS 10 or above,

It will open the Settings but then crash it. The reason, there's nothing in settings for your app.

Below code will open your application settings inside the iOS Setting.

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
}

Due to device unavailability, I couldn't check this on iOS < 10.

Also, I could find below code from some gist and it works fine on iOS 10 as well. But I am not sure if this will approve by Apple review team or not.

https://gist.github.com/johnny77221/bcaa5384a242b64bfd0b8a715f48e69f

无所谓啦 2024-11-08 03:29:32

由于 openURL(_:) 在 iOS 10.0 后已被弃用,因此请使用 open(_:options:completionHandler:) 代替。

if let settingsUrl = URL(string: UIApplication.openSettingsURLString)  {
        UIApplication.shared.open(settingsUrl, options: [:]) { completed in
             if !completed {
                 print("Failed opening")
             }
        }
}

As openURL(_:) is deprecated after iOS 10.0, use open(_:options:completionHandler:) instead.

if let settingsUrl = URL(string: UIApplication.openSettingsURLString)  {
        UIApplication.shared.open(settingsUrl, options: [:]) { completed in
             if !completed {
                 print("Failed opening")
             }
        }
}
蝶舞 2024-11-08 03:29:32

您可以使用下面的代码。

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

You can use the below code for it.

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
说不完的你爱 2024-11-08 03:29:32

使用 iOS 10 进行测试。

NSArray* urlStrings = @[@"prefs:root=WIFI", @"App-Prefs:root=WIFI"];
for(NSString* urlString in urlStrings){
NSURL* url = [NSURL URLWithString:urlString];
if([[UIApplication sharedApplication] canOpenURL:url]){
    [[UIApplication sharedApplication] openURL:url];
    break;
}
}

快乐编码:)

Tested with iOS 10. Working

NSArray* urlStrings = @[@"prefs:root=WIFI", @"App-Prefs:root=WIFI"];
for(NSString* urlString in urlStrings){
NSURL* url = [NSURL URLWithString:urlString];
if([[UIApplication sharedApplication] canOpenURL:url]){
    [[UIApplication sharedApplication] openURL:url];
    break;
}
}

Happy Coding :)

失与倦" 2024-11-08 03:29:32

SWIFT 4.0

“openURL”在 iOS 10.0 中已弃用:请使用
openURL:options:completionHandler: 改为

UIApplication.shared.open(URL.init(string: UIApplicationOpenSettingsURLString)! , options: [:], completionHandler: nil)

SWIFT 4.0

'openURL' was deprecated in iOS 10.0: Please use
openURL:options:completionHandler: instead

UIApplication.shared.open(URL.init(string: UIApplicationOpenSettingsURLString)! , options: [:], completionHandler: nil)
无戏配角 2024-11-08 03:29:32

Swift 4

我更喜欢以更安全的方式打开设置,

if let settingUrl = URL(string:UIApplicationOpenSettingsURLString) {

    UIApplication.shared.open(settingUrl)
}
else {
    print("Setting URL invalid")
}

Swift 4

I prefer to open setting in a safer way,

if let settingUrl = URL(string:UIApplicationOpenSettingsURLString) {

    UIApplication.shared.open(settingUrl)
}
else {
    print("Setting URL invalid")
}
豆芽 2024-11-08 03:29:32

从 iOS 16 开始,您可以使用 openSettingsURLString

if let url = URL(string: UIApplication. openSettingsURLString) {
    await UIApplication.shared.open(url)
}

From iOS 16, you can use openSettingsURLString

if let url = URL(string: UIApplication. openSettingsURLString) {
    await UIApplication.shared.open(url)
}
野却迷人 2024-11-08 03:29:32

迅速
您可以使用以下功能通过蓝牙页面打开设置应用程序

func openSettingsApp(){
    if let settings = NSURL(string: "prefs:root=Bluetooth") {
        UIApplication.sharedApplication().openURL(settings)
    }
}

,但这不会打开应用程序的设置。这将打开带有蓝牙的设置应用程序,因为这是与蓝牙的深度链接。

Swift
You can use following function to open Settings App with Bluetooth Page

func openSettingsApp(){
    if let settings = NSURL(string: "prefs:root=Bluetooth") {
        UIApplication.sharedApplication().openURL(settings)
    }
}

Again this would not open the App's Settings. This would open settings app with Bluetooth as this is deep linking to bluetooth.

我早已燃尽 2024-11-08 03:29:32

要添加到接受的答案:(来自苹果开发人员文档)“当您打开从此字符串 (openSettingsURLString) 构建的 URL 时,系统将启动“设置”应用程序并显示该应用程序的自定义设置(如果有)。”因此,如果您想打开应用程序的设置,请创建您自己的 Settings.bundle。

To add to accepted answer: (from apple developer documentation) "When you open the URL built from this string (openSettingsURLString), the system launches the Settings app and displays the app’s custom settings, if it has any." So, if you want to open settings for your app, create your own Settings.bundle.

睫毛上残留的泪 2024-11-08 03:29:32

将其添加到您的班级中,

 public class func showSettingsAlert(title:String,message:String,onVC viewController:UIViewController,onCancel:(()->())?){
            YourClass.show2ButtonsAlert(onVC: viewController, title: title, message: message, button1Title: "Settings", button2Title: "Cancel", onButton1Click: {
                if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString){
                    UIApplication.sharedApplication().openURL(settingsURL)
                }
                }, onButton2Click: {
                    onCancel?()
            })
        }

 public class func show2ButtonsAlert(onVC viewController:UIViewController,title:String,message:String,button1Title:String,button2Title:String,onButton1Click:(()->())?,onButton2Click:(()->())?){
            dispatch_async(dispatch_get_main_queue()) {
                let alert : UIAlertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)

                alert.addAction(UIAlertAction(title: button1Title, style:.Default, handler: { (action:UIAlertAction) in
                    onButton1Click?()
                }))

                alert.addAction(UIAlertAction(title: button2Title, style:.Default, handler: { (action:UIAlertAction) in
                    onButton2Click?()
                }))

                viewController.presentViewController(alert, animated: true, completion: nil)
            }
        }

像这样调用,

YourClass.showSettingsAlert("App would like to access camera", message: "App would like to access camera desc", onVC: fromViewController, onCancel: {
  print("canceled")
})

Add this to your class,

 public class func showSettingsAlert(title:String,message:String,onVC viewController:UIViewController,onCancel:(()->())?){
            YourClass.show2ButtonsAlert(onVC: viewController, title: title, message: message, button1Title: "Settings", button2Title: "Cancel", onButton1Click: {
                if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString){
                    UIApplication.sharedApplication().openURL(settingsURL)
                }
                }, onButton2Click: {
                    onCancel?()
            })
        }

 public class func show2ButtonsAlert(onVC viewController:UIViewController,title:String,message:String,button1Title:String,button2Title:String,onButton1Click:(()->())?,onButton2Click:(()->())?){
            dispatch_async(dispatch_get_main_queue()) {
                let alert : UIAlertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)

                alert.addAction(UIAlertAction(title: button1Title, style:.Default, handler: { (action:UIAlertAction) in
                    onButton1Click?()
                }))

                alert.addAction(UIAlertAction(title: button2Title, style:.Default, handler: { (action:UIAlertAction) in
                    onButton2Click?()
                }))

                viewController.presentViewController(alert, animated: true, completion: nil)
            }
        }

Call like this,

YourClass.showSettingsAlert("App would like to access camera", message: "App would like to access camera desc", onVC: fromViewController, onCancel: {
  print("canceled")
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文