Like many apps, my iOS app offers the user a chance to open the app's settings page if a certain privacy permission has been disabled.
In iOS, using the special UIApplicationOpenSettingsURLString
/ openSettingsURLString
URL takes the user to the app specific page of the Settings app. There the user sees various privacy settings used by the app in addition to any settings setup in the Settings.bundle provided by the app (if any).
While working on the Mac Catalyst port of the iOS app, this is not working as hoped. The same use of the special settings URL displays the same preferences pane the user sees when clicking on the "Preferences..." menu. And this is only what is provided by the app's Settings.bundle. The app's privacy settings are not shown like in iOS.
I can see my app's privacy settings in the macOS Settings app by clicking on "Security & Privacy", then the Privacy tab, and then clicking on the appropriate item in the list on the left such as Contacts or Photos. But these settings are not grouped by the app.
Is there any way to get the macOS version of an iOS app to show the various privacy settings in one place like when run on iOS? If not, is there at least a way to directly launch the Settings app in macOS and display the Privacy pane?
This isn't exactly the same as what you get in iOS but it's as close as I think you can get. Based on information found on this answer to Cocoa button opens a System Preference page I updated my code as follows:
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)!)
Here's the URLs for some likely privacy settings:
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
Note: While this works in development, I don't yet know for sure if this will be approved for the App Store.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With