OS X系统偏好设置URL方案 [英] OS X System Preferences URL Scheme

查看:156
本文介绍了OS X系统偏好设置URL方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过链接打开通知"首选项窗格(在OS X SystemPreferences.app中).到目前为止,前缀x-apple.systempreferences://可以用于打开系统偏好设置应用程序,但是我想直接打开通知窗格,并且(在最佳情况下)甚至可以从列表中选择我的应用程序.

I’m trying to open the Notifications preference pane (in OS X SystemPreferences.app) via a link. The prefix x-apple.systempreferences:// works so far for opening the system preferences app, but I’d like to open the notifications pane directly and (in the best case) even select my app in the list.

有人知道SystemPreferences.app在通过其URL方案打开时是否确实接受了任何参数吗?

Does anybody know whether the SystemPreferences.app does take any arguments when opened via its URL-Scheme?

我已经尝试过x-apple.systempreferences://Notificationsx-apple.systempreferences://Notifications.prefPane,但是其他参数将被忽略.

I already tried x-apple.systempreferences://Notifications and x-apple.systempreferences://Notifications.prefPane, but the additional arguments are simply ignored.

谢谢!

顺便说一句:是的,我知道我可以通过openFile:轻松打开Notifications.prefPane文件,但是我想知道是否可以通过URL.

BTW: Yes, I know I could easily open the Notifications.prefPane file via openFile:, but I’d like to know if it’s possible via URL.

推荐答案

您可以使用首选项窗格的捆绑包标识符通过URL方案打开首选项窗格:

You can open a preference pane via the URL scheme using the preference pane's bundle identifier:

x-apple.systempreferences:com.apple.preference.notifications

如果您需要通过此方案引用锚,则可以使用查询参数进行引用:

If you need to reference an anchor via this scheme you can do so using a query parameter:

x-apple.systempreferences:com.apple.preferences.sharing?Services_ScreenSharing

请注意,此方案是10.10中的新增功能.如果需要支持以前的版本,请使用AppleScript或文件打开方法.

Note that this scheme is new in 10.10. Use AppleScript or the file open method if support for previous releases is required.

更新:Apple在10.11中限制了URL方案的使用.从此版本开始,只能通过URL方案打开在Info.plist中设置为NSPrefPaneAllowsXAppleSystemPreferencesURLScheme的首选项窗格.

Update: Apple has restricted use of the URL scheme in 10.11. As of this release only preference panes with NSPrefPaneAllowsXAppleSystemPreferencesURLScheme set in their Info.plist can be opened via the URL scheme.

这篇关于OS X系统偏好设置URL方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆