max*_*max 9 macos cocoa url-scheme system-preferences
我正在尝试通过链接打开通知首选项窗格(在OS X SystemPreferences.app中).x-apple.systempreferences://到目前为止,前缀用于打开系统首选项应用程序,但我想直接打开通知窗格(在最好的情况下)甚至在列表中选择我的应用程序.
有没有人知道SystemPreferences.app是否通过其URL-Scheme打开时是否接受任何参数?
我已经尝试过x-apple.systempreferences://Notifications和x-apple.systempreferences://Notifications.prefPane,但额外的参数被忽略.
谢谢!
顺便说一句:是的,我知道我可以轻松打开Notifications.prefPane文件openFile:,但我想知道是否可以通过URL.
Mat*_*ens 16
您可以使用首选项窗格的包标识符通过URL方案打开首选项窗格:
x-apple.systempreferences:com.apple.preference.notifications
Run Code Online (Sandbox Code Playgroud)
如果需要通过此方案引用锚点,可以使用查询参数来执行此操作:
x-apple.systempreferences:com.apple.preferences.sharing?Services_ScreenSharing
Run Code Online (Sandbox Code Playgroud)
请注意,此方案是10.10中的新方案.如果需要支持以前的版本,请使用AppleScript或文件打开方法.
更新:Apple在10.11中限制使用URL方案.在此版本中,只能NSPrefPaneAllowsXAppleSystemPreferencesURLScheme通过URL方案打开其Info.plist中带有set的首选项窗格.