This repository has been archived by the owner on Apr 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
1.1 iOS Integration
pJes2 edited this page Apr 26, 2016
·
8 revisions
- Get an API Key
- Go to Filepicker.io to register an account.
- API Keys are typically randomized and 20 characters long.
- Add
FPPicker
to yourPodfile
platform :ios, '8.0'
use_frameworks!
target :'MyImagesApp' do
pod 'FPPicker', '~> 5.1.6'
end
-
Run
pod install
-
Setup
-
Add
@import FPPicker;
to your app delegate (i.e., typicallyAppDelegate.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"; }
-
In Use
-
@import FPPicker;
into yourViewController.h
or anywhere else you may want to use Filepicker. -
Make your controller conform to the FPPickerControllerDelegate (and optionally to the FPSaveControllerDelegate):
objc @interface ViewController () <FPPickerControllerDelegate, FPSaveControllerDelegate> @end
-
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";
(...)
```
- 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
}
(...)
```