OS X System Preferences URL Scheme

限于喜欢 提交于 2019-12-03 07:38:14

问题


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.

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

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

Thanks!

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.


回答1:


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

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

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.



来源:https://stackoverflow.com/questions/24701362/os-x-system-preferences-url-scheme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!