MBFacebookImagePicker 1.0.4

MBFacebookImagePicker 1.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Mikael Bäckman.



 
Depends on:
FBSDKCoreKit~> 4.21.0
FBSDKLoginKit~> 4.21.0
 

  • By
  • mikaelbo



Swift version

A simple image picker for Facebook written in Swift. Looks and works very similar to the native UIImagePickerController, except it uses a completion block instead of a delegate protocol.

Requirements

  • Xcode 8
  • iOS 8.0+ target deployment
  • FBSDKCoreKit, FBSDKLoginKit (>= 4.0)
  • Swift 3 project

Installation

Manually

Download the project or clone the repo. Import the MBImagePicker folder into your project. Make sure you have the FBSDKCoreKit, FBSDKCoreKit, and Bolts frameworks imported.

Running the example project

Usage

Make sure that your application has been setup with the Facebook SDK.

Import the library:

import MBFacebookImagePicker

Show the picker:

let imagePicker = MBFacebookImagePickerController()
imagePicker.finishedCompletion = { [weak self] (result) in
    self?.dismiss(animated: true, completion: nil)
    switch result {
        case .completed(let image): self?.imageView.image = image
        case .failed(let error): print("failed with error: \(error)")
        case .cancelled: print("Cancelled!")
    }
}
present(imagePicker, animated: true, completion: nil)

Note that the app needs to have been authenticated with Facebook and given permission to access user_photos before showing the image picker.

Translations

MBImagePicker uses the following translation keys:

"MBIMAGEPICKER_NO_ALBUMS_FOUND"     = "No albums found";
"MBIMAGEPICKER_ALBUMS"              = "Albums";

"MBIMAGEPICKER_ERROR_ALERT_TITLE"   = "Ooops...";
"MBIMAGEPICKER_NETWORK_ERROR"       = "Network unavailable, please try again";
"MBIMAGEPICKER_UNKNOWN_ERROR"       = "Something went wrong, please try again";

"MBIMAGEPICKER_NO_PICTURES_FOUND"   = "Could not find any pictures\nin your photo album";

"MBIMAGEPICKER_CANCEL"              = "Cancel";
"MBIMAGEPICKER_OK"                  = "OK";

Add the keys to your localizable.strings and modify the strings for you respective language(s).

License

MBFacebookImagePicker is available under the MIT license. See the LICENSE file for more info.