mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
parent
14e41a31ef
commit
f3e698f1be
@ -52,6 +52,7 @@ import { ImagePicker } from './plugins/imagepicker';
|
||||
import { ImageResizer } from './plugins/imageresizer';
|
||||
import { InAppBrowser } from './plugins/inappbrowser';
|
||||
import { Insomnia } from './plugins/insomnia';
|
||||
import { Instagram } from './plugins/instagram';
|
||||
import { Keyboard } from './plugins/keyboard';
|
||||
import { LaunchNavigator } from './plugins/launchnavigator';
|
||||
import { LocalNotifications } from './plugins/localnotifications';
|
||||
@ -151,6 +152,7 @@ export {
|
||||
GoogleAnalytics,
|
||||
Hotspot,
|
||||
Insomnia,
|
||||
Instagram,
|
||||
Keyboard,
|
||||
NativeAudio,
|
||||
NativeStorage,
|
||||
@ -225,6 +227,7 @@ window['IonicNative'] = {
|
||||
ImagePicker: ImagePicker,
|
||||
ImageResizer: ImageResizer,
|
||||
InAppBrowser: InAppBrowser,
|
||||
Instagram: Instagram,
|
||||
Keyboard: Keyboard,
|
||||
LaunchNavigator: LaunchNavigator,
|
||||
LocalNotifications: LocalNotifications,
|
||||
|
57
src/plugins/instagram.ts
Normal file
57
src/plugins/instagram.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
|
||||
/**
|
||||
* @name Instagram
|
||||
* @description Share a photo with the instagram app
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* import {Instagram} from 'ionic-native';
|
||||
*
|
||||
* Instagram.share('data:image/png;uhduhf3hfif33', 'Caption')
|
||||
* .then(() => console.log('Shared!'))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
plugin: 'cordova-instagram-plugin',
|
||||
pluginRef: 'Instagram',
|
||||
repo: 'https://github.com/vstirbu/InstagramPlugin'
|
||||
})
|
||||
export class Instagram {
|
||||
|
||||
/**
|
||||
* Detect if the Instagram application is installed on the device.
|
||||
*
|
||||
* @return {Promise<boolean|string>} Returns a promise that returns a boolean value if installed, or the app version on android
|
||||
*/
|
||||
@Cordova({
|
||||
callbackStyle: 'node'
|
||||
})
|
||||
static isInstalled(): Promise<boolean|string> {return;}
|
||||
|
||||
/**
|
||||
* Share an image on Instagram
|
||||
* Note: Instagram app stopped accepting pre-filled captions on both iOS and Android. As a work-around, the caption is copied to the clipboard. You have to inform your users to paste the caption.
|
||||
*
|
||||
* @param canvasIdOrDataUrl The canvas element id or the dataURL of the image to share
|
||||
* @param caption The caption of the image
|
||||
* @return {Promise<any>} Returns a promise that resolves if the image was shared
|
||||
*/
|
||||
@Cordova({
|
||||
callbackStyle: 'node'
|
||||
})
|
||||
static share(canvasIdOrDataUrl: string, caption?: string): Promise<any> {return;}
|
||||
|
||||
/**
|
||||
* Share a library asset or video
|
||||
* @param assetLocalIdentifier A local fileURI
|
||||
* @return {Promise<any>} Returns a promise that resolves if the image was shared
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
static shareAsset(assetLocalIdentifier: string): Promise<any> {return;}
|
||||
|
||||
}
|
@ -48,6 +48,14 @@ function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Func
|
||||
// Get those arguments in the order [resolve, reject, ...restOfArgs]
|
||||
args.unshift(reject);
|
||||
args.unshift(resolve);
|
||||
} else if (opts.callbackStyle === 'node') {
|
||||
args.push((err, result) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
} else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') {
|
||||
// If we've specified a success/error index
|
||||
args.splice(opts.successIndex, 0, resolve);
|
||||
|
Loading…
Reference in New Issue
Block a user