FacebookImagePicker is Facebook album photo picker written in Swift.

Overview

FacebookImagePicker

Cocoapods version Cocoapods licence Cocoapods plateform Prs welcome

FeaturesInstallationUsageTranslationLicense

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

  • Login with Facebook SDK and display user's Albums or tagged photos
  • Display pictures of each albums
  • Handling denied Facebook photo's permission
  • Multiple selection in one album
  • Select all

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
  • Then, implement the GBHFacebookImagePickerDelegate protocol :
// 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
}
  • Display picker :
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

  • About tagged photos : the tagged photos are displayed in an album (hide by default, see customisation section to display it) with the name "Photos of You". You can change this default name in the settings. The tagged album's cover is the facebook account profile picture, which are retrieved with a special call to the graph API.

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

  • Xcode 11.4
  • iOS 9.0+ target deployment
  • FBSDKCoreKit, FBSDKLoginKit (>= 7.0 for the v5.0)
  • Facebook Application, see usage for explaination
  • Swift 3, 4, 4.2 or 5.1 project

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

  • If you need help, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request and read the contributing file.

Author

Florian Gabach, [email protected]

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.

Comments
  • Getting This Error In Simulator Unable To Load Album.

    Getting This Error In Simulator Unable To Load Album.

    Xcode Version :- Version 8.1 (8B62) Swift version 3.0.1 Simulator Version :- 10.1

    When I Click The Button To Pick Image From Facebook

    It asked for permission first and i allowed it. it then loads a blank page and i get this in the console.

    simulator screen shot dec 16 2016 2 07 29 pm

    2016-12-16 14:04:32.039 MemE[7911:99405] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2016-12-16 14:04:32.041 MemE[7911:99405] Falling back to storing access token in NSUserDefaults because of simulator bug 2016-12-16 14:04:32.046 MemE[7911:99405] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2016-12-16 14:04:41.582216 MemE[7911:106868] [] nw_host_stats_add_src recv too small, received 24, expected 28 2016-12-16 14:04:41.597632 MemE[7911:106868] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available" 2016-12-16 14:04:41.611015 MemE[7911:106868] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace: [x86_64] libnetcore-856.20.4 0 libsystem_network.dylib 0x0000000105f8e682 __nw_create_backtrace_string + 123 1 libnetwork.dylib 0x0000000107d06932 nw_socket_add_input_handler + 3100 2 libnetwork.dylib 0x0000000107ce44f4 nw_endpoint_flow_attach_protocols + 3768 3 libnetwork.dylib 0x0000000107ce3511 nw_endpoint_flow_setup_socket + 563 4 libnetwork.dylib 0x0000000107ce2270 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612 5 libnetwork.dylib 0x0000000107cfd44d nw_endpoint_handler_path_change + 1261 6 libnetwork.dylib 0x0000000107cfce7c nw_endpoint_handler_start + 570 7 libnetwork.dylib 0x0000000107d14ae5 nw_endpoint_resolver_start_next_child + 2240 8 libdispatch.dylib 0x0000000105d0b980 _dispatch_call_block_and_release + 12 9 libdispatch.dylib 0x0000000105d350cd _dispatch_client_callout + 8 10 libdispatch.dylib 0x0000000105d12e6b _dispatch_queue_serial_drain + 236 11 libdispatch.dylib 0x0000000105d13b9f _dispatch_queue_invoke + 1073 12 libdispatch.dylib 0x0000000105d163b7 _dispatch_root_queue_drain + 720 13 libdispatch.dylib 0x0000000105d1608b _dispatch_worker_thread3 + 123 14 libsystem_pthread.dylib 0x00000001060de4de _pthread_wqthread + 1129 15 libsystem_pthread.dylib 0x00000001060dc341 start_wqthread + 13

    help wanted 
    opened by thrijith 12
  • Endless Activity Indicator when calling presentFacebookAlbumImagePicker

    Endless Activity Indicator when calling presentFacebookAlbumImagePicker

    Hello - Since the most recent update, when I call presentFacebookAlbumImagePicker, it presents the picker correctly, but never shows any images, no Facebook login screen, nothing.

    • In the console I see : Found 31 album(s) with this Facebook account. • The error or success delegate methods are never called.

    Not really sure what other info I can share.. It was definitely working well in the last version. Any thoughts?

    bug 
    opened by RGBNu 11
  • Type 'SelectPhotosViewController' does not conform to protocol 'FacebookImagePickerDelegate'

    Type 'SelectPhotosViewController' does not conform to protocol 'FacebookImagePickerDelegate'

    Hi, I get the error found in the title even though I add the protocol subs to fix it, but then the same error comes back.

    This is what's not recognized as part of the protocol even though it's what the autocomplete fills in:

    func facebookImagePicker(imagePicker: UIViewController, successImageModels: [FacebookImage], errorImageModels: [FacebookImage], errors: [Error?]) {
        allPhotos.append(contentsOf: successImageModels)
        collectionView.reloadData()
    }
    

    I'm running the most recent version of all pods.

    How do I fix this?

    help wanted 
    opened by michaeldebo 9
  • Tagged photos

    Tagged photos

    Would that be possible to get the photo where I am tagged and all of them gathered in "an album" called "Photos of me" for example?

    Cheers

    enhancement question 
    opened by nico75005 8
  • Profile picture not loading on first click

    Profile picture not loading on first click

    After login facebook all album loaded but when click on profile picture then images are not loading on first click as same happens for timeline photos loader is spinning as long as have open the screen but go back and once again click on profile picture then images loaded. FIrst time user experience goes very bad. Find my attachment WhatsApp Image 2019-07-29 at 12 28 18

    bug 
    opened by pradeepkatiyar 6
  • Fixed FBSDK versions

    Fixed FBSDK versions

    This commit fixes a issue, to include the newest FBSDK while including multiple version of FBSDK while using this library.

    Please see attached image for fixed error message:

    screen shot 2018-06-08 at 19 54 10
    opened by pak-amsiq 6
  • Multiple selection is not available

    Multiple selection is not available

    Hello.

    Check your documentation. And find that library allow multiple selection. But not there is no this parameter in settings.

    It will be great if you add it.

    Thanks.

    help wanted 
    opened by IlyaBaudin 6
  • White browser page after authorization

    White browser page after authorization

    When I launch the picker, I always get the authorization page in Facebook. After the login and the permission agreement the web view is blank and the only button is "Done" which close and cancel the picker. Any ideas?

    question 
    opened by ramirez 5
  • No such module 'GBHFacebookImagePicker'

    No such module 'GBHFacebookImagePicker'

    After including the library in the podfile and doing 'pod install' in terminal, terminal lists this library among the pods successfully installed. However, I'm getting a 'no such module' error upon trying to import GBHFacebookImagePicker. I have tried restarting Xcode and reinstalling the pod. There was another issue with this error, but the poster closed it without a solution.

    opened by tcliff111 4
  • Swift/Objective-C Facebook asks for login twice, won't display photos

    Swift/Objective-C Facebook asks for login twice, won't display photos

    I am writing an iOS app, in which the base of the application is written in Objective-C. I however am writing a file in Swift, and am using this Swift Facebook image picker, with pod FBSDKCoreKit 4.29 and FBSDKLoginKit 4.29 in my podfile. My App delegate is also in Objective-C.

    When I activate this FacebookImagePicker while using the app, I am again prompted to login with Facebook, and if I login the screen is white and blank. Any idea why?

    opened by kornha 4
  • Add custom color for Picker's Nav Bar Background

    Add custom color for Picker's Nav Bar Background

    If setting your app's color scheme in AppDelegate, this picker will not conform to a chosen pickerStyle. This proposed change would allow you to set a custom color when presenting the picker.

    opened by mgt-la 3
Releases(6.0.0)
Owner
Florian Gabach
French software engineer
Florian Gabach
A photo gallery for iOS with a modern feature set. Similar features as the Facebook photo browser.

EBPhotoPages ”A photo gallery can become a pretty complex component of an app very quickly. The EBPhotoPages project demonstrates how a developer coul

Eddy Borja 1.7k Dec 8, 2022
AR相册 Photo Album For AR

HeavenMemoirs - AR相册 线上地址 https://itunes.apple.com/cn/app/weare/id1304227680?mt=8 HeavenMemoirs 技术点 AR初始化 在新建项目时可以直接创建 AR 项目, xcode 会创造一个 AR 项目的模板. 也可

Heikki 677 Dec 6, 2022
Jogendra 113 Nov 28, 2022
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift

SKPhotoBrowser [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-) Simple PhotoBrowser

keishi suzuki 2.4k Jan 6, 2023
DGCropImage - A photo cropping tool which mimics Photo.app written by Swift

DGCropImage A photo cropping tool which mimics Photo.app written by Swift. This

donggyu 11 Jul 14, 2022
📷 multiple phassets picker for iOS lib. like a facebook

Written in Swift 5.0 TLPhotoPicker enables application to pick images and videos from multiple smart album in iOS, similar to the current facebook app

junhyi park 1.8k Jan 2, 2023
Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more

IDMPhotoBrowser IDMPhotoBrowser is a new implementation based on MWPhotoBrowser. We've added both user experience and technical features inspired by F

Thiago Peres 2.7k Dec 21, 2022
A framework that lists all photos in the album that contain faces.

FaceCollectionViewKit A framework that lists all photos in the album that contain faces. Features It uses the detection features of CIDetectorTypeFace

Serhat Akalın 2 Aug 30, 2022
Photo-Sharing-App - Photo Sharing App With Swift

Photo Sharing App You can register and log in to this application and share your

Yağız Savran 2 Jun 14, 2022
FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor

FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor Quick demo Batch select/deselect Smoo

Cong Nguyen 648 Dec 27, 2022
Custom iOS camera and photo picker with editing capabilities

Overview Paparazzo is a component for picking and editing photos. Key Features ?? Taking photos using camera ?? Picking photos from user's photo libra

avito.tech 757 Jan 4, 2023
WLPhotoPicker - A multifunction photo picker for iOS

WLPhotoPicker Example To run the example project, clone the repo, and run pod in

Weang 20 Nov 25, 2022
React-native-photo-editor - Photo editor using native modules for iOS and Android

?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, ZLImageEditor (iOS) and PhotoEditor (Android)

Baron Ha. 244 Jan 5, 2023
Image picker with custom crop rect for iOS written in Swift (Ported over from GKImagePicker)

WDImagePicker Ever wanted a custom crop area for the UIImagePickerController? Now you can have it with WDImagePicker. Just set your custom crop area a

Wu Di 96 Dec 19, 2022
A Shortcuts-like and highly customizable SFSymbol picker written in Swift.

SFTintedIconPicker SFTintedIconPicker is a Shortcuts-like and highly customizable SFSymbol picker written in Swift. Features Native Appearance Search

StephenFang 2 Aug 16, 2022
iOS photo gallery written in Swift

SwiftPhotoGallery Overview A full screen photo gallery for iOS and tvOS written in Swift. Photos can be panned and zoomed (iOS only) Pinch to zoom (iO

Justin Vallely 271 Dec 17, 2022
Nilay Dagdemir 0 Jan 23, 2022
PhotoApp - A Simple Photo App using Swift and MVC pattern

PhotoApp A Simple Photo App using Swift and MVC pattern After App launch, you wi

null 2 Aug 14, 2022
📸 Instagram-like image picker & filters for iOS

YPImagePicker YPImagePicker is an instagram-like photo/video picker for iOS written in pure Swift. It is feature-rich and highly customizable to match

Yummypets 4k Dec 27, 2022