与许多应用程序一样,如果禁用了某些隐私权限,我的 iOS 应用程序将为用户提供打开应用程序设置页面的机会。
在iOS中,使用特殊的UIApplicationOpenSettingsURLString
/ openSettingsURLString
URL 将用户带到“设置”应用程序的应用程序特定页面。除了应用程序提供的 Settings.bundle 中的任何设置(如果有)之外,用户还可以在其中看到应用程序使用的各种隐私设置。
在开发 iOS 应用程序的 Mac Catalyst 端口时,这并没有按预期工作。特殊设置 URL 的相同使用会显示用户在单击“首选项...”菜单时看到的相同首选项窗格。这只是应用程序的 Settings.bundle 提供的内容。该应用程序的隐私设置不像 iOS 那样显示。
我可以在 macOS 设置应用程序中查看我的应用程序的隐私设置,方法是依次单击“安全和隐私”、“隐私”选项卡,然后单击左侧列表中的相应项目,例如“联系人”或“照片”。但这些设置不按应用程序分组。
有没有办法让 macOS 版本的 iOS 应用程序在一个地方显示各种隐私设置,就像在 iOS 上运行时一样?如果没有,是否至少有一种方法可以直接在 macOS 中启动“设置”应用程序并显示“隐私”窗格?
这与你在 iOS 中得到的并不完全相同,但它是我认为你能得到的最接近的了。根据找到的信息这个答案 https://stackoverflow.com/a/48139877/1226963 to Cocoa 按钮打开系统偏好设置页面 https://stackoverflow.com/questions/6652598/cocoa-button-opens-a-system-preference-page我更新了我的代码如下:
Objective-C:
NSString *url;
#if TARGET_OS_MACCATALYST
url = @"x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars"; // Update as needed
#else
url = UIApplicationOpenSettingsURLString;
#endif
[UIApplication.sharedApplication openURL:[NSURL URLWithString:url] options:@{} completionHandler:nil];
Swift:
let url: String
#if targetEnvironment(macCatalyst)
url = "x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars" // Update as needed
#else
url = UIApplication.openSettingsURLString
#endif
UIApplication.shared.open(URL(string: url)!)
以下是一些可能的隐私设置的 URL:
Privacy x-apple.systempreferences:com.apple.preference.security?Privacy
Privacy-Photos x-apple.systempreferences:com.apple.preference.security?Privacy_Photos
Privacy-Camera x-apple.systempreferences:com.apple.preference.security?Privacy_Camera
Privacy-Microphone x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone
Privacy-Location x-apple.systempreferences:com.apple.preference.security?Privacy_LocationServices
Privacy-Contacts x-apple.systempreferences:com.apple.preference.security?Privacy_Contacts
Privacy-Calendars x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars
Privacy-Reminders x-apple.systempreferences:com.apple.preference.security?Privacy_Reminders
注意:虽然这正在开发中,但我还不确定这是否会被 App Store 批准。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)