Home

Awesome

<p align="center"> <img src="https://github.com/terflogag/FacebookImagePicker/blob/master/Ressources/welcome_img.png" alt="FacebookImagePicker" /> </p> <p align="center"> <a href="https://cocoapods.org/pods/GBHFacebookImagePicker" target="_blank"><img src="https://img.shields.io/cocoapods/v/GBHFacebookImagePicker.svg?style=flat" alt="Cocoapods version" /></a> <a href="http://cocoapods.org/pods/GBHFacebookImagePicker" target="_blank"><img src="https://img.shields.io/cocoapods/l/GBHFacebookImagePicker.svg?style=flat" alt="Cocoapods licence" /></a> <a href="http://cocoapods.org/pods/GBHFacebookImagePicker" target="_blank"><img src="https://img.shields.io/cocoapods/p/GBHFacebookImagePicker.svg?style=flat" alt="Cocoapods plateform" /></a> <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="Prs welcome" /> </p> <p align="center"> <a href="#features">Features</a> • <a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#translation">Translation</a> • <a href="#license">License</a> </p>

GBHFacebookImagePicker is Facebook's album photo picker written in Swift, built to provide a simple way to pick picture into Facebook account. The picker provides a simple interface like the native iOS photo picker. This picker takes care of all authentication (from the web or with the native Facebook app) when necessary. If the photo's permission isn't accepted during the login, the picker prompts another permission's request.

Screenshot / Demo

Preview

Features

Example

In your terminal :

pod try GBHFacebookImagePicker

Or to run the example project manually, clone the repo, and run pod install from the Example directory first.

Don't forget to replace the current Facebook App's ID with your own in the plist file (Open as > Source code). Like this :

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
            <array>
                <string>fb<YOUR_FACEBOOK_APP_ID></string>
            </array>
    </dict>
</array>
<key>FacebookAppID</key>
<string><YOUR_FACEBOOK_APP_ID></string>

Just in case, for public application (which can be use in the AppStore), you need to send your Facebook's App in review to have user's photos permission.

Usage

import GBHFacebookImagePicker
// MARK: - GBHFacebookImagePicker Protocol

func facebookImagePicker(imagePicker: UIViewController,
                         successImageModels: [GBHFacebookImage],
                         errorImageModels: [GBHFacebookImage],
                         errors: [Error?]) {
    // Append selected image(s)
    // Do what you want with selected image 
    self.imageModels.append(contentsOf: successImageModels)
}

func facebookImagePicker(imagePicker: UIViewController, didFailWithError error: Error?) {
    print("Cancelled Facebook Album picker with error")
    print(error.debugDescription)
}

// Optional
func facebookImagePicker(didCancelled imagePicker: UIViewController) {
    print("Cancelled Facebook Album picker")
}

// Optional
func facebookImagePickerDismissed() {
    print("Picker dismissed")
}

The imageModel contain :

public class FacebookImage {
    public var image: UIImage? // The image, not nil only if image is selected
    public var normalSizeUrl: String? // Normal size picture url
    public var fullSizeUrl: String? // Full size source picture url
    public var imageId: String? // Picture id
}
let picker = FacebookImagePicker() 
picker.presentFacebookAlbumImagePicker(from: self, delegate: self) 

Customisation

You can apply some customisation. To do it you can use the FacebookPickerConfig structure.

Aditionals informations

Translation

FacebookImagePicker is currently written in english. If you need translation for the permission popup (or whatever thing), just add this line in your localized file :

"Pictures" = "<your_translation>";
"Oups" = "<your_translation>";
"You need to allow photo's permission." =  "<your_translation>";
"Allow" = "<your_translation>";
"Close" = "<your_translation>";
"Album(s)" = "<your_translation>";
"Photos of You" = "<your_translation>";
""No picture(s) in this album." = "<your_translation>";"

Requirements

Installation

FacebookImagePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "GBHFacebookImagePicker"

pod "GBHFacebookImagePicker", '~> 2.4' # For swift 4.0

pod "GBHFacebookImagePicker", '~> 1.3.1' # For Swift 3.1

Communication

Author

Florian Gabach, florian.gabach@gmail.com

License

FacebookImagePicker is available under the MIT license.

If your application use this picker consider to add the licence in your Credits/About section. You can use this library to do it.