Maninderjit Singh
Maninderjit Singh

Reputation: 1456

how to get Permissions for photos access in iOS 9 with photos framework

I want to get photos through photos framework in iOS9 with Swift 2.photos framework is not allowed to access images and not asking permissions for access.

Upvotes: 1

Views: 1606

Answers (1)

Maninderjit Singh
Maninderjit Singh

Reputation: 1456

Simply add Photos framework in "Link Binary With Libraries" under build phases,Then import framework in class where its required.

To access photos permissions you need to give "Bundle display name" in plist file

and use following code

PHPhotoLibrary.requestAuthorization { (status) -> Void in

            switch status{
            case .Authorized:
                dispatch_async(dispatch_get_main_queue(), {
                    print("Authorized")
                 })
                break
            case .Denied:
                dispatch_async(dispatch_get_main_queue(), {
                    print("Denied")
                })
                break
            default:
                dispatch_async(dispatch_get_main_queue(), {
                    print("Default")
                })
                break
            }
        }

Upvotes: 3

Related Questions