1

My ios 7 app is not asking for permission to view photos. If I delete the app off my device, then build and run again on xcode to install it to the device, whenever the app starts up I can go check the privacy settings and it shows that it has access to photos, even though I never recieved the message box that asks for it like it does location services. I have an imagepicker that is displayed modally at one point during my app and its having issues with displaying a black image preview and I believe its being caused by this photos access issue.

Does anyone know why this is happening?

edit: also, after my app starts, if I go into the privacy settings and change the photo permissions from on to off the app crashes. no warning or error, just crashes.

Stonep123
  • 615
  • 3
  • 9
  • 24
  • See http://stackoverflow.com/questions/13635288/ios-calendar-access-permission-dialog-force-it-to-appear/13693935#13693935. This applies to all of the privacy settings. – rmaddy Dec 20 '13 at 21:08
  • Also see http://stackoverflow.com/questions/12810638/app-crashed-in-ios-6-when-user-changes-contacts-access-permissions/12810719#12810719 for info on your "edit". – rmaddy Dec 20 '13 at 21:09
  • @rmaddy, interesting. thanks for the help! – Stonep123 Dec 21 '13 at 17:23

1 Answers1

0

I was having a similar problem. Creating a NSPhotoLibraryUsageDescription key in the info.plist should fix this, but it doesn't, here is a programming fix:

func photoLibraryAvailabilityCheck() {
    let status = PHPhotoLibrary.authorizationStatus()
    if (status == PHAuthorizationStatus.authorized) {
        print("PHAuthorizationStatus.authorized")
    }       else if (status == PHAuthorizationStatus.denied) {
        print("PHAuthorizationStatus.denied")
        requestPhotosLibraryAccess()
    }       else if (status == PHAuthorizationStatus.notDetermined) {
        print("PHAuthorizationStatus.notDetermined")
        requestPhotosLibraryAccess()
    }       else if (status == PHAuthorizationStatus.restricted) {
        print("PHAuthorizationStatus.restricted")
    }
}

func requestPhotosLibraryAccess() {
    PHPhotoLibrary.requestAuthorization({ (newStatus) in
        if (newStatus == PHAuthorizationStatus.authorized) {
            print("pressed the allowed button")
        }       else {
            print("pressed the don't allow button")
        }
    })
}

To Use:

photoLibraryAvailabilityCheck()
Bobby
  • 6,115
  • 4
  • 35
  • 36