ios7 app not asking for permission to access photos

1.8k Views Asked by At

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.

1

There are 1 best solutions below

0
On

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()