2018-03-17 14:33:21 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
|
|
|
|
2018-04-12 15:54:00 +09:30
|
|
|
export interface IOSFilePickerPosition {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
width: number;
|
|
|
|
height: number;
|
2018-04-13 12:41:45 +02:00
|
|
|
}
|
2018-04-12 15:54:00 +09:30
|
|
|
|
2018-03-17 14:33:21 +01:00
|
|
|
/**
|
2018-03-22 12:12:52 +01:00
|
|
|
* @name iOS File Picker
|
2018-03-17 14:33:21 +01:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Opens the file picker on iOS for the user to select a file, returns a file URI.
|
|
|
|
*
|
|
|
|
* @usage
|
|
|
|
* ```typescript
|
|
|
|
* import { IOSFilePicker } from '@ionic-native/file-picker';
|
|
|
|
*
|
|
|
|
* constructor(private filePicker: IOSFilePicker) { }
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
* this.filePicker.pickFile()
|
|
|
|
* .then(uri => console.log(uri))
|
|
|
|
* .catch(err => console.log('Error', err));
|
|
|
|
*
|
|
|
|
* ```
|
2018-04-12 15:54:00 +09:30
|
|
|
* @interfaces
|
|
|
|
* IOSFilePickerPosition
|
2018-03-17 14:33:21 +01:00
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
pluginName: 'iOS File Picker',
|
|
|
|
plugin: 'cordova-plugin-filepicker',
|
2018-04-04 14:17:47 +09:30
|
|
|
pluginRef: 'FilePicker',
|
2018-03-17 14:33:21 +01:00
|
|
|
repo: 'https://github.com/jcesarmobile/FilePicker-Phonegap-iOS-Plugin',
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
@Injectable()
|
|
|
|
export class IOSFilePicker extends IonicNativePlugin {
|
|
|
|
/**
|
|
|
|
* Open a file
|
2018-04-12 15:54:00 +09:30
|
|
|
* @params {string | string[]} [utis]
|
|
|
|
* @params {IOSFilePickerPosition} [position] Set the position of the rectangle where the file picker should show up.
|
2018-03-17 14:33:21 +01:00
|
|
|
* @returns {Promise<string>}
|
|
|
|
*/
|
2018-04-12 15:54:00 +09:30
|
|
|
@Cordova({
|
|
|
|
callbackOrder: 'reverse'
|
|
|
|
})
|
|
|
|
pickFile(
|
|
|
|
utis?: string | string[],
|
|
|
|
position?: IOSFilePickerPosition
|
|
|
|
): Promise<string> {
|
2018-03-17 14:33:21 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|