Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

1.3 iOS Integration (Swift)

pJes2 edited this page Apr 26, 2016 · 7 revisions
  1. Get an API Key
  • Go to Filepicker.io to register an account.
  • API Keys are typically randomized and 20 characters long.
  1. Add FPPicker to your Podfile
platform :ios, '8.0'

use_frameworks!

target :'MyImagesApp' do
  pod 'FPPicker', '~> 5.1.6'
end
  1. Run pod install
  2. Setup
  • Create new file Bridge.h and add to your project
  • In project settings set path to file Bridge.h in property Objective-C Bridging Header
  • Add imports #import "FPPicker.h" and #import FPExternalHeaders.h to Bridge.h
  • Add the following code on your app delegate and use the API Key you got after registering:
  func initalize(){
      FPConfig.sharedInstance().APIKey = "SET_FILEPICKER.IO_APIKEY_HERE";
  }
  1. In Use

    • Make your controller conform to the FPPickerControllerDelegate (and optionally to the FPSaveControllerDelegate):
    • Instantiate the objects and configure them
     var picker:FPPickerController = FPPickerController();
     picker.fpdelegate = self;
    (...)
    
    var saveController:FPSaveController = FPSaveController();
    saveController.fpdelegate = self;
    (...)
    • Implement the delegate methods
    func fpPickerController(pickerController: FPPickerController!, didFinishPickingMediaWithInfo info: FPMediaInfo!) {
      // Handle accordingly
    }
    
    func fpPickerControllerDidCancel(pickerController: FPPickerController!) {
       // Handle accordingly
    }
    
    func fpSaveController(saveController: FPSaveController!, didFinishSavingMediaWithInfo info: FPMediaInfo!) {
       // Handle accordingly
    }
    
    func fpSaveControllerDidCancel(saveController: FPSaveController!) {
       // Handle accordingly
    }
    
    (...)
Clone this wiki locally