67

I'm trying to recreate the condition where the following code returns AVAuthorizationStatusNotDetermined:

AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];

However, the iPad appears to remember camera permissions even after the app is deleted and reinstalled, and so either Authorized or NotAuthorized is returned every time. Any idea how to reset the permissions so that NotDetermined is returned?

Thanks for reading.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rogare
  • 3,234
  • 3
  • 27
  • 50

4 Answers4

125

You can't reset the permission programmatically. If you want to reset the permission there are two ways:

  1. Reset the OS
  2. Uninstall the app and wait for a day

I know both of those options are really not helpful for a developer, if they are trying to test it out something.

There are three alternatives for testing your app's first run scenario without resetting the entire OS or waiting a day.

First option

As described in Technical Note TN2265 :

You can achieve the latter without actually waiting a day by following these steps:

  • Delete your app from the device.
  • Turn the device off completely and turn it back on.
  • Go to Settings > General > Date & Time and set the date ahead a day or more.
  • Turn the device off completely again and turn it back on.

Second option

When you delete an app the iOS keeps the permission of your app mapped to your app's bundle id, it keeps the data for day. So you can also change your app's bundle id to test it out.

Third Option

As suggested by @rmaddy in the comment you can reset all location and privacy permissions : Settings -> General -> Reset -> Reset Location & Privacy. Note that this will reset all location and privacy permissions for all the apps on that device.

Community
  • 1
  • 1
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • 3
    This works, thanks! I also found that just changing the Bundle Identifier in XCode did the trick as well. – Rogare Dec 31 '14 at 21:35
  • 1
    @Rogare: Yes, that will also help, because after deleting the app, iOS keeps the permissions mapped with your app's bundle id for a day. So either you can change the bundle id or the date – Midhun MP Dec 31 '14 at 21:37
  • 27
    Why not simply do it the easy way? Settings -> General -> Reset -> Rest Location & Privacy – rmaddy Jan 01 '15 at 00:23
  • @rmaddy: It'll reset the settings for all the apps installed on that device. – Midhun MP Jan 01 '15 at 03:32
  • But it's a development device so it doesn't really matter. :) – rmaddy Jan 01 '15 at 05:40
  • 2
    @rmaddy: Yes, that's true :) (But I use my own device for development). Happy New Year :) – Midhun MP Jan 01 '15 at 05:42
  • 2
    Prefer the second solution,just change key "CFBundleIdentifier"'s value in Info.plist,build and run your app,the camera permission prompt is showing up,and it is much faster than the first one when testing. – tounaobun Mar 03 '15 at 07:28
  • @MidhunMP do you know where can I find in the apple documentation, something related to keeping the permissions for a day after uninstalling? – razvan Mar 09 '18 at 15:35
  • @razvan: As mentioned in my answer, please go to the technical note link. And search for the "Resetting the Push Notifications Permissions Alert on iOS" section. – Midhun MP Mar 12 '18 at 07:51
  • the 3rd option should really be the 1st option – Fero Mar 31 '21 at 09:00
  • I can't imagine we need to deal with this in 2022. – Matin Zadeh Dolatabad Dec 11 '22 at 18:52
1

This is no longer an issue if you update OS version on your device to the latest. It didnt work on 13.3.1 but it did clear permissions after 13.4.1

Jay Seong
  • 11
  • 1
  • 4
    Still an issue on iOS 13.5.1. I have to clear privacy & location settings to test camera authorisation. Otherwise it doesn't ask even after delete, restart, re-install. – Gary M Jul 03 '20 at 08:03
  • 1
    Still getting the issue in iOS 13.5 – Ankur Lahiry Jul 15 '20 at 14:32
  • Just tested with Xcode 12.4 on an iOS Simulator 14.4 and a real device iOS 14.5 beta 3. No issue at all. – Owen Zhao Mar 12 '21 at 11:21
1

On iOS 14 go to Settings->Privacy->Location Services, select the app and for allow location access pick "Ask Next Time"

enter image description here

malhal
  • 26,330
  • 7
  • 115
  • 133
  • These instructions are for Location Services, but the question is about Camera permission. There is no option for "ask next time" with the Camera. – huwr Apr 08 '22 at 05:56
1

What worked for me:

Windows -> Devices And Simulators -> Installed Apps section

Remove the app from there using the - button.

4b0
  • 21,981
  • 30
  • 95
  • 142
Mooshy
  • 75
  • 1
  • 7
  • 2
    https://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplicate-answer-to-several-questions – Yunnosch Jan 26 '21 at 07:24