1

I've an iphone app where the user is able to upload photos. During test on ios simulator, everytime I click the "upload image" button, the simulator pops up an alert that says I should give the app permission to access photo albums.

The problem is that the simulator never asked me before if I want to give it access or not. And when I go to privacy settings on the simulator -> photos, I do no see the app to toggle it ON!

I tried resetting content & settings of the simulator, but that didn't solve the problem.

I'm using xCode 5.0.2 Simulator 7.0 iOS 6.1 simulator component

  • When you click on the "upload image" button, are you calling `UIImagePickerController` somewhere? – jbouaziz Feb 17 '14 at 16:43
  • I did reset the settings for location & privacy from inside the simulator, and that didn't solve it. The app still pops up an alert that I should give it permission, but it does not ask me if I want or not, and it does not show up on photo privacy either. – Mohammad Alfares Feb 17 '14 at 16:49
  • Calling AGImagePickerController – Mohammad Alfares Feb 17 '14 at 20:28

3 Answers3

0

did you check Settings->Privacy->Photos? you should allow your app have full access here.

Jerry Juang
  • 127
  • 1
  • 2
0

add following code to somewhere

UIImagePickerController* picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[self presentViewController:picker animated:YES completion:Nil];

remember to add this function to handle picked image

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissViewControllerAnimated:YES completion:nil];
}

try this then to see what happened on your machine.

Jerry Juang
  • 127
  • 1
  • 2
0

I found the problem

There is code

   if (status != ALAuthorizationStatusAuthorized) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please give the app access to photo album" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil];

[alert show]; }

I changed:

if (status != ALAuthorizationStatusAuthorized) {

to

if (status == ALAuthorizationStatusDenied) {

Then it worked and asked me for permission, accepted it, and everything is ok now

Thanks everyone