mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 11:41:20 +08:00
feat(plugins): CameraRoll
This commit is contained in:
45
ionic/plugins/camera-roll/camera-roll.ts
Normal file
45
ionic/plugins/camera-roll/camera-roll.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import * as Rx from 'rx';
|
||||
|
||||
import * as util from 'ionic/util';
|
||||
import {NativePlugin} from '../plugin';
|
||||
|
||||
/**
|
||||
* Manage the appearance of the native status bar.
|
||||
*/
|
||||
@NativePlugin({
|
||||
name: 'CameraRoll',
|
||||
platforms: ['ios'],
|
||||
engines: {
|
||||
cordova: 'cordova-plugin-camera-roll'
|
||||
},
|
||||
pluginCheck: () => {
|
||||
return !!window.CameraRoll;
|
||||
}
|
||||
})
|
||||
export class CameraRoll {
|
||||
/**
|
||||
* Save the base64 encoded image to the camera roll.
|
||||
*/
|
||||
static save(base64String) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.ifPlugin(() => {
|
||||
window.CameraRoll.saveToCameraRoll(base64String, () => {
|
||||
resolve();
|
||||
}, (err) => {
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get photos from the camera roll
|
||||
*/
|
||||
static getPhotos(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.ifPlugin(() => {
|
||||
window.CameraRoll.saveToCameraRoll(base64String);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user