24

When I access my Photo Library with an UIImagePicker to choose a photo, the app shows me sometimes a black screen and sometimes a screen that says that I have to give permissions to my app to access the photos. But when I go to Settings -> Privacy -> Photos, there’s no app there and the app is nowhere to be seen in Settings. I read that I must add two values to my Info.plist but they didn’t worked either. Have anyone run with the same error? I’m working with xcode 7, swift 2.0 and iOS 9

enter image description here

This is where i prompt for user for Camera access

@IBAction func cameraButtonPressed(sender: UIButton) {

    let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

    let cancelAction = UIAlertAction(title: "Cancel", style: .Default) { (UIAlertAction) -> Void in
        self.dismissViewControllerAnimated(true, completion: nil)
    }

    let cameraAction = UIAlertAction(title: "Take Photo", style: .Default) { (UIAlertAction) -> Void in
        if UIImagePickerController.availableCaptureModesForCameraDevice(.Rear) != nil {
            self.imagePicker.allowsEditing = false
            self.imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
            self.imagePicker.cameraCaptureMode = .Photo
            self.presentViewController(self.imagePicker, animated: true, completion: nil)
        } else {
            self.noCamera()
        }
    }

    let photoLibraryAction = UIAlertAction(title: "Photo Library", style: .Default) { (UIAlertAction) -> Void in
        self.imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
        self.presentViewController(self.imagePicker, animated: true, completion: nil)
    }

    actionSheet.addAction(photoLibraryAction)
    actionSheet.addAction(cameraAction)
    actionSheet.addAction(cancelAction)

    self.presentViewController(actionSheet, animated: true, completion: nil)

}
Manuel Munoz
  • 753
  • 1
  • 6
  • 15
  • 1
    Does your app actually request access or not? – Chris Slowik Sep 24 '15 at 18:17
  • @ChrisSlowik It actually doesnt show the dialog requesting permission – Manuel Munoz Sep 24 '15 at 18:27
  • Do you tell it to in your code? I'm asking what you've done. You give no indication that you actually are doing what should be done to request access, so its hard to say what's wrong. If you haven't told your app to request permission, thats your problem. Otherwise you may have another issue. – Chris Slowik Sep 24 '15 at 18:30
  • You say: "This is where i prompt for user for Camera access". I say where? I see no code in there prompting for camera access. – Gruntcakes Sep 24 '15 at 21:29
  • I asked a similar question with some more details, still haven't been able to figure it out: http://stackoverflow.com/questions/32834212/phphotolibrary-requestauthorization-not-triggering-authorization-prompt-on-ios-9 – MC. Sep 29 '15 at 02:21
  • I faced same issue on iOS 10.1 simulator and any solution does not work. – Capella Nov 02 '16 at 17:50

7 Answers7

54

This issue appear in iOS 9 when your application Info.plist file contains a key: "CFBundleDisplayName" with empty string value.

You can enter your app name there and it should work.

Vijay D. Gupta
  • 578
  • 5
  • 4
  • 2
    I have been searching this answer for ages. Thanks! – arjunaskykok Oct 03 '15 at 01:30
  • 2
    Cannot get it to works here.... It asked permission the first time only. Added Bundle display name, changed it to different strings, empty also, deleted app, DerivedData, clean project, restart simulator. Since then, cannot get it to present the popup dialog again. – bauerMusic Jan 29 '16 at 11:15
  • Thanks so much you're my hero! – flo bee Feb 01 '16 at 19:06
  • @bauerMusic. Did you fixed issue? – Avijit Nagare Feb 02 '16 at 13:11
  • @AvijitNagare After further reading, seems to be by design. Opened here (more specifically) http://stackoverflow.com/questions/35083401/phphotolibrary-requestauthorization-not-requesting/35084315#35084315 – bauerMusic Feb 02 '16 at 14:11
  • @bauerMusic. i used third party library,issue might be due to this.it work for me on simulator only not on device – Avijit Nagare Feb 02 '16 at 14:50
  • @Vijay D. Gupta Thanks so much,its work for me in camera access in card.io library – Ashiwani Feb 17 '16 at 06:59
7

In info.plist, "Bundle display name" field can not be empty.

Example

5

If you are getting this screen there are probably below reasons and solutions :

1.If you are not getting access permission alert.

Solution : 1. Add CFBundleDisplayName and its value as you application title or anything you want. 2. Add NSPhotoLibraryUsageDescription in info.plist file

2.Check your Settings -> Privacy -> Photos, privacy is disabled or enable.

Solution : Enable privacy for photos.

3.If you are working on simulator and have already added CFBundleDisplayName not getting alert for photo access.

Solation : Make sure Xcode you are using must be in Application folder to get permission access alert.

Himanshu jamnani
  • 316
  • 2
  • 10
1

For those still getting this error in iOS 10, it is a question of new Privacy settings implemented in iOS 10.

Basically, in the Info.plist, you have to state why you want to access the Photo library by setting the Privacy - Photo Library Usage Description key (note, this can be left to a blank string).

More about it here: http://useyourloaf.com/blog/privacy-settings-in-ios-10/

Benjamin
  • 8,128
  • 3
  • 34
  • 45
1

I realize that this is an old question, but have one other last-ditch tip to offer...

After trying the above suggestions, I still had Camera, Photos, Music Library permissions issues on an iPod touch running iOS 9.3. The Settings app > Privacy > Photos listed no apps (neither did Privacy > Camera, or Privacy > Media Library). The Settings app did not contain a row for my app, so there was no way for customers to change my app's Privacy permissions.

The solution was to open the Settings app > General > Reset, then tap Reset Location & Privacy. Apparently, my device's privacy settings had somehow become corrupted. After the reset, all these issues were resolved.

lifjoy
  • 2,158
  • 21
  • 19
1

FOR iOS10 In info.plist

"CFBundleDisplayName" enter your app name

<key>CFBundleDisplayName</key>
<string>IMS Food-taxi</string> 

and "NSPhotoLibraryUsageDescription" add description

<key>NSPhotoLibraryUsageDescription</key>
<string>you will need to give the app permission to use the Photos.</string>
Nazmul Hasan
  • 10,130
  • 7
  • 50
  • 73
0

it is very simple,

just go in

simulator -> hardware -> Home

then in phone's settings -> in your app -> now allow by move switch option like below image