21

iOS is not asking user for Photo Library Permission anymore. Even when I deleted the app from the device. This also happens on Simulator.

switch ([ALAssetsLibrary authorizationStatus])
{
    case ALAuthorizationStatusAuthorized:
        RPMLog(@"authorized");
        break;
    case ALAuthorizationStatusDenied:
        RPMLog(@"denied");
        break;
    case ALAuthorizationStatusNotDetermined:
        RPMLog(@"not determined");
        break;
    case ALAuthorizationStatusRestricted:
        RPMLog(@"restricted");
        break;
}

I'm already authorized when I install the app for the first time. Prior to this, there's no other event or screen that asks for the photos to trigger the user prompt.

Then I request the numberOfAssets in SavedPhotos and get it without the access prompt:

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {

    if (!group) return;

    UIActionSheet *actionSheet = nil;
    if (([group numberOfAssets] > 0))
    {
        actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"Take new photo", nil), NSLocalizedString(@"Use last photo taken", nil), NSLocalizedString(@"Choose existing", nil), nil];
    }
    else
    {
        actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"Take new photo", nil), NSLocalizedString(@"Choose existing", nil), nil];
    }

    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    [actionSheet showFromTabBar:self.tabBar];
    [TestFlight passCheckpoint:@"New Look: Tab Bar"];

} failureBlock:^(NSError *error) {

    NSAssert(!error, [error description]);
}];
Lucien
  • 7,795
  • 4
  • 27
  • 30
  • 1
    This is likely because iOS remembers settings like these for 24 hours - I have experienced the same thing when deleting an app that I was testing push notifications on. If you override the system clock by a day and restart, you may get the popup back. – Luke Jan 10 '13 at 17:10
  • I tried settings the device clock 2 days ahead (then 2 days before), resetting the device and making a clean install, didn't work - still not asking permission. – Lucien Jan 10 '13 at 17:21
  • 5
    You need to reset the privacy settings. Run the Settings app and go to General, then Reset. Tap on "Reset Location & Privacy". This resets all privacy settings though. – rmaddy Jan 10 '13 at 17:51
  • You are right, I did this on the Simulator and had no success, but on the device it worked. – Lucien Jan 10 '13 at 19:51
  • This is no longer a problem in iOS 10. It forgets the setting for Photos, Camera, etc. as soon as the app is deleted. – Dan Loughney Sep 08 '16 at 21:17

6 Answers6

36

As the question is for Photo Library permissions, there is other way without changing the system clock and turning the device off.

You can just go to "Settings" app

(General > Reset > Reset Location & Privacy).

This will make the apps ask for photo library, location and other permissions again.

jcesarmobile
  • 45,750
  • 8
  • 107
  • 152
  • 2
    This worked for me, I needed to reset the permissions for access to the Photo Library, and this was a quick solution. Of course, it means having to confirm choices I've made for other apps, but it worked. – lshepstone Dec 26 '13 at 12:43
  • By far better than the given solution, that pretty muches takes about 3 minutes to achieve whenever you want to test. – Gil Sand Sep 01 '15 at 15:52
26

What is happening is iOS is saving the permission granted to your app mapped to the bundle ID, if the app is deleted this data persists for 24 hours, this avoids re prompting the user if they reinstall the app (perhaps after mistakingly deleting an app).

This also happens for Push Notification prompts.

As a workaround, I quote Apple concerning the Push Notifications:

Resetting the Push Notifications Permissions Alert on iOS

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on.

Source: Apple Technical Note TN2265

Daniel
  • 22,521
  • 12
  • 107
  • 150
1

Restting via the settings app is difficult to automate. We use simctl to reset the simulators content and settings in an automated fashion to reset the permissions dialog. This will require re-installing the app in the simulator, but again simctl can accomplish this.

sidekickr
  • 328
  • 3
  • 7
1

You can check this permission by two types -

  • In Simulator
    you can do Simulator/Reset Content and Settings.
  • In Physical device (iPhone, iPad)
    You can change date, at least difference should be 24 hours.

but first uninstall app from device then restart then apply this thing then it will work.

0

If you are using the iOS Simulator, resetting it using Simulator/Reset Content and Settings... seems to reset this setting. Of course, you'll then need to reinstall your app onto it.

Andrew Ferrier
  • 13,902
  • 11
  • 40
  • 73
-3

You just need to follow bellow point no need to reinstall or delete app.

  • App remove from background
  • Go to Settings->General->Reset-> click on Reset Location & Privacy

Hope you got help.

Bhavesh Kumbhani
  • 555
  • 4
  • 10
  • 1
    A duplicate of the second best answer. If you want to add information about removing an app from the background, edit @jcesarmobile original answer. – Tomasz Bąk Oct 30 '14 at 14:33