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

1.1 iOS Integration

pJes2 edited this page Apr 26, 2016 · 8 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

  • Add @import FPPicker; to your app delegate (i.e., typically AppDelegate.m)

  • Add the following code on your app delegate and use the API Key you got after registering:

    + (void)initialize
    {
        [FPConfig sharedInstance].APIKey = @"SET_FILEPICKER.IO_APIKEY_HERE";
    }
  1. In Use

  2. @import FPPicker; into your ViewController.h or anywhere else you may want to use Filepicker.

  3. Make your controller conform to the FPPickerControllerDelegate (and optionally to the FPSaveControllerDelegate): objc @interface ViewController () <FPPickerControllerDelegate, FPSaveControllerDelegate> @end

  4. Instantiate the objects and configure them ```objc FPPickerController pickerController = [FPPickerController new]; pickerController.fpdelegate = self; pickerController.dataTypes = @[@"image/"]; (...)

FPSaveController *saveController = [FPSaveController new];
saveController.fpdelegate = self;
saveController.data = fileData;
saveController.dataType = @"image/png";
(...)

```
  1. Implement the delegate methods ```objc #pragma mark - FPPickerController Delegate Methods
- (void)fpPickerController:(FPPickerController *)pickerController didFinishPickingMediaWithInfo:(FPMediaInfo *)info
{
  // Handle accordingly
}

- (void)fpPickerControllerDidCancel:(FPPickerController *)pickerController
{
  // Handle accordingly
}

#pragma mark - FPSaveController Delegate Methods

- (void)fpSaveController:(FPSaveController *)saveController didFinishSavingMediaWithInfo:(FPMediaInfo *)info
{
  // Handle accordingly
}

- (void)fpSaveControllerDidCancel:(FPSaveController *)saveController
{
  // Handle accordingly
}

(...)
```
Clone this wiki locally