Search code examples
iosswiftiphonepermissionsaccessibility

Can we disable App level permissions by programming in swift?


I need to manage app-level permissions that are device-specific. there are 4 permissions:

  1. faceID login
  2. camera
  3. storage
  4. location

What I need to develop is, if I enable-disable switches on these permissions, it should be reflected on app settings too. for eg. If I have disabled camera permission; it should show disable in settings-> privacy -> camera -> App (disabled) Is this possible?

Current development: I have enabled it all by default. and stored it in UserDefaults. Whenever a user wants to access the feature, I check the value stored in UserDefault. Allow if enabled and show a message if disabled. But disabled doesn't mean it's disabled from the device settings. I hope I've explained my question properly :/


Solution

  • You cannot programmatically remove a permission you have been granted.

    Once you have a permission you have it until the user turns it off in settings.

    Accordingly, it doesn't make sense to provide a UI to disable permissions in your app.

    What you can do is provide a UI to disable features that use those permissions. For example, a switch to turn on/off "Login with FaceId" or "Report my location"; if the switch is off your app might still have the permission, but your app won't make use of it.