Latest 1.0.4
Homepage https://github.com/mikaelbo/MBFacebookImagePicker
License MIT
Platforms ios 8.0
Dependencies FBSDKCoreKit, FBSDKLoginKit
Authors

ImagePicker

Version
Platform
License

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 4 project

Installation

CocoaPods

Add the following line to your Podfile:

pod "MBFacebookImagePicker"

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

With CocoaPods

Enter the following line in your terminal:

pod try MBFacebookImagePicker

If you instead chose to download or clone the project directly, you must first run pod install from the Example directory to install all dependencies.

Also make sure to replace FacebookAppID under URL types and FacebookAppID in info.plist.

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

Latest podspec

{
    "name": "MBFacebookImagePicker",
    "version": "1.0.4",
    "summary": "A simple image picker for Facebook written in Swift.",
    "homepage": "https://github.com/mikaelbo/MBFacebookImagePicker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "mikaelbo": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mikaelbo/MBFacebookImagePicker.git",
        "tag": "1.0.4"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MBFacebookImagePicker/**/*",
    "dependencies": {
        "FBSDKCoreKit": [
            "~> 4.21.0"
        ],
        "FBSDKLoginKit": [
            "~> 4.21.0"
        ]
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This