【问题标题】:Is there a way to send the user to the app's privacy settings under macOS like we do in iOS?有没有办法像我们在 iOS 中那样在 macOS 下将用户发送到应用程序的隐私设置?
【发布时间】:2020-02-08 08:27:38
【问题描述】:

与许多应用一样,如果某个隐私权限已被禁用,我的 iOS 应用会为用户提供打开应用设置页面的机会。

在 iOS 中,使用特殊的 UIApplicationOpenSettingsURLString / openSettingsURLString URL 将用户带到“设置”应用的应用特定页面。除了应用程序提供的 Settings.bundle 中的任何设置设置(如果有)之外,用户还可以看到应用程序使用的各种隐私设置。

在 iOS 应用程序的 Mac Catalyst 端口上工作时,这并没有像希望的那样工作。特殊设置 URL 的相同使用显示了用户在单击“首选项...”菜单时看到的相同首选项窗格。这只是应用程序的 Settings.bundle 提供的内容。该应用的隐私设置不像 iOS 中那样显示。

我可以在 macOS 设置应用程序中查看我的应用程序的隐私设置,方法是单击“安全和隐私”,然后单击“隐私”选项卡,然后单击左侧列表中的相应项目,例如“联系人”或“照片”。但这些设置并未按应用分组。

有没有办法让 macOS 版本的 iOS 应用程序在一个地方显示各种隐私设置,就像在 iOS 上运行时一样?如果没有,是否至少有一种方法可以直接在 macOS 中启动“设置”应用并显示“隐私”窗格?

【问题讨论】:

    标签: ios mac-catalyst


    【解决方案1】:

    这与你在 iOS 中得到的并不完全相同,但它与我认为你能得到的一样接近。根据在this answerCocoa button opens a System Preference page 上找到的信息,我将代码更新如下:

    目标-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];
    

    斯威夫特:

    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:

    隐私 x-apple.systempreferences:com.apple.preference.security?Privacy 隐私照片 x-apple.systempreferences:com.apple.preference.security?Privacy_Photos 隐私相机 x-apple.systempreferences:com.apple.preference.security?Privacy_Camera 隐私麦克风 x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone 隐私位置 x-apple.systempreferences:com.apple.preference.security?Privacy_LocationServices 隐私-联系人 x-apple.systempreferences:com.apple.preference.security?Privacy_Contacts 隐私日历 x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars 隐私提醒 x-apple.systempreferences:com.apple.preference.security?Privacy_Reminders

    注意:虽然这在开发中有效,但我不确定这是否会在 App Store 中获得批准。

    【讨论】:

    • 这是否最终通过了 App Store 审核?
    猜你喜欢
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2012-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多