Skip to content

Spark-Networks/FacebookImagePicker

 
 

Repository files navigation

GBHFacebookImagePicker

Version License Platform PRs Welcome Swift 3 compatible

GBHFacebookImagePicker is Facebook album photo picker written in Swift 3.0.

Screenshot / Demo

Video demonstration -> https://vimeo.com/192823627

Preview

Features

  • Login with Facebook SDK and display user's Albums
  • Display pictures of each albums
  • Handling denied Facebook photo's permission
  • Select and get URL/Image of the picked picture
  • UI Customization
  • AppStore ready
  • Swift 3
  • iPhone/iPad support
  • Unit & UI Test
  • Multiple selection

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 forgot 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.

Requirements

  • Xcode 8
  • iOS 9.0+ target deployment
  • FBSDKCoreKit, FBSDKLoginKit (>= 4.0)
  • Facebook Application, see usage for explaination
  • Swift 3 project

Installation

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

pod "GBHFacebookImagePicker"

Usage

import GBHFacebookImagePicker
  • Then, implement the GBHFacebookImagePickerDelegate protocol :
// MARK: - GBHFacebookImagePicker Protocol

func facebookImagePicker(imagePicker: UIViewController, imageModel: GBHFacebookImageModel) {
    // Do whatever you whant with the image model ...
}

func facebookImagePicker(imagePicker: UIViewController, didFailWithError error: Error?) {
    print(error.debugDescription)
}

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

The imageModel contain :

public class GBHFacebookImageModel {
    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
}
  • Display picker :
let picker = GBHFacebookImagePicker() 
picker.presentFacebookAlbumImagePicker(from: self, delegate: self) 

Customization

The are three style : .facebook (default style), .light & .dark.

GBHFacebookImagePicker.pickerConfig.ui.style = .facebook

Translation

GBHFacebookImagePicker is currently write 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>";

Alternative solutions

Here are some other Facebook's album picker libraries.

Applications

Some applications already use this picker like :

What about yours ? If your application also use this picker, feel free to contact me or make pull request on the README 😁

Author

Florian Gabach, contact@floriangabach.fr

Inspired by OceanLabs/FacebookImagePicker-iOS (Objective-C)

License

GBHFacebookImagePicker is available under the MIT license.

About

GBHFacebookImagePicker is Facebook album photo picker written in Swift.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 98.3%
  • Ruby 1.7%