GBHFacebookImagePicker is Facebook album photo picker written in Swift 3.0.
Video demonstration -> https://vimeo.com/192823627
- 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
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.
- Xcode 8
- iOS 9.0+ target deployment
- FBSDKCoreKit, FBSDKLoginKit (>= 4.0)
- Facebook Application, see usage for explaination
- Swift 3 project
GBHFacebookImagePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "GBHFacebookImagePicker"
-
You need to set up your application correctly to work with Facebook : https://developers.facebook.com/docs/ios/getting-started and https://developers.facebook.com/docs/ios/ios9
-
Import the library :
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)
The are three style : .facebook (default style), .light & .dark.
GBHFacebookImagePicker.pickerConfig.ui.style = .facebook
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>";
Here are some other Facebook's album picker libraries.
- sanche21/DSFacebookImagePicker
- OceanLabs/FacebookImagePicker-iOS
- bradtheappguy/BSFacebookImagePicker
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 😁
Florian Gabach, contact@floriangabach.fr
Inspired by OceanLabs/FacebookImagePicker-iOS (Objective-C)
GBHFacebookImagePicker is available under the MIT license.