Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* });
*
* let watch = this.geolocation.watchPosition();
* watch.subscribe((data) => {
* // data can be a set of coordinates, or an error (if an error occurred).
* // data.coords.latitude
* // data.coords.longitude
* });
* ```
* @interfaces
* Coordinates
* Geoposition
* PositionError
* GeolocationOptions
*/
@Plugin({
pluginName: 'Geolocation',
plugin: 'cordova-plugin-geolocation',
pluginRef: 'navigator.geolocation',
repo: 'https://github.com/apache/cordova-plugin-geolocation',
install:
'ionic cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="To locate you"',
installVariables: ['GEOLOCATION_USAGE_DESCRIPTION'],
platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Windows']
})
@Injectable()
export class Geolocation extends IonicNativePlugin {
/**
* Get the device's current position.
*
* @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
* @returns {Promise} Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error.
* Destroy a panorama completely
* @return {Promise}
*/
@CordovaInstance()
remove(): Promise {
return getPromise((resolve) => {
this._objectInstance.remove(() => resolve());
});
}
}
/**
* @hidden
*/
@Plugin({
pluginName: 'GoogleMaps',
plugin: 'cordova-plugin-googlemaps'
})
export class GoogleMap extends BaseClass {
constructor(element: HTMLElement | string, options?: GoogleMapOptions, __timeout?: number) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
// ---------------
// Create a map
// ---------------
if (element instanceof HTMLElement) {
if (!element.offsetParent) {
throw new Error('Element must be under ');
}
if (element.offsetWidth >= 100 && element.offsetHeight >= 100) {
super(GoogleMaps.getPlugin().Map.getMap(element, options));
return getPromise>((resolve, reject) => {
GoogleMaps.getPlugin().Geocoder.geocode(request, (mvcArray: any) => {
if (mvcArray) {
resolve(new BaseArrayClass(mvcArray));
} else {
reject();
}
});
});
} else {
// -------------------------
// Geocoder.geocode({
// address: "Kyoto, Japan"
// })
// -------------------------
return getPromise((resolve, reject) => {
GoogleMaps.getPlugin().Geocoder.geocode(request, (results: GeocoderResult[]) => {
if (results) {
resolve(results);
} else {
reject();
}
});
});
}
}
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
// ---------------
// Create a map
// ---------------
if (element instanceof HTMLElement) {
if (!element.offsetParent) {
throw new Error('Element must be under ');
}
if (element.offsetWidth >= 100 && element.offsetHeight >= 100) {
super(GoogleMaps.getPlugin().Map.getMap(element, options));
} else {
throw new Error(element.tagName + ' is too small. Must be bigger than 100x100.');
}
} else if (typeof element === 'string') {
super(GoogleMaps.getPlugin().Map.getMap(getPromise((resolve, reject) => {
let count: number;
let i: number;
count = 0;
const timer: any = setInterval(() => {
let targets: any[];
for (i = 0; i < TARGET_ELEMENT_FINDING_QUERYS.length; i++) {
targets = Array.from(document.querySelectorAll(TARGET_ELEMENT_FINDING_QUERYS[i] + element));
if (targets.length > 0) {
targets = targets.filter((target) => {
return !target.hasAttribute('__pluginmapid');
});
}
if (targets.length === 1 && targets[0] && targets[0].offsetWidth >= 100 && targets[0].offsetHeight >= 100) {
clearInterval(timer);
resolve([targets[0], options]);
return;
* Bind a key to another object
* @param key {string} The property name you want to observe.
* @param target {any} The target object you want to observe.
* @param targetKey? {string} [options] The property name you want to observe. If you omit this, the `key` argument is used.
* @param noNotify? {boolean} [options] True if you want to prevent `(key)_changed` event when you bind first time, because the internal status is changed from `undefined` to something.
*/
@CordovaInstance({ sync: true })
bindTo(key: string, target: any, targetKey?: string, noNotify?: boolean): void {
}
/**
* Alias of `addEventListener`
* @param key {string} The property name you want to observe.
* @return {Observable}
*/
@InstanceCheck({ observable: true })
on(eventName: string): Observable {
return new Observable((observer) => {
this._objectInstance.on(eventName, (...args: any[]) => {
const newArgs = normalizeArgumentsOfEventListener.call(this, this._objectInstance, args);
observer.next(newArgs);
});
});
}
/**
* Alias of `addThrottledEventListener`
* @param key {string} The property name you want to observe.
* @return {Observable}
*/
// @InstanceCheck({ observable: true })
// onThrottled(eventName: string): Observable {
*
* @usage
* ```typescript
* import { Instagram } from '@ionic-native/instagram';
*
* constructor(private instagram: Instagram) { }
*
* ...
*
* this.instagram.share('data:image/png;uhduhf3hfif33', 'Caption')
* .then(() => console.log('Shared!'))
* .catch((error: any) => console.error(error));
*
* ```
*/
@Plugin({
pluginName: 'Instagram',
plugin: 'cordova-instagram-plugin',
pluginRef: 'Instagram',
repo: 'https://github.com/vstirbu/InstagramPlugin',
platforms: ['Android', 'iOS']
})
@Injectable()
export class Instagram extends IonicNativePlugin {
/**
* Detect if the Instagram application is installed on the device.
*
* @returns {Promise} Returns a promise that returns a boolean value if installed, or the app version on android
*/
@Cordova({
callbackStyle: 'node'
*
* constructor(private base64ToGallery: Base64ToGallery) { }
*
*
* ...
*
*
* this.base64ToGallery.base64ToGallery(base64Data, { prefix: '_img' }).then(
* res => console.log('Saved image to gallery ', res),
* err => console.log('Error saving image to gallery ', err)
* );
* ```
* @interfaces
* Base64ToGalleryOptions
*/
@Plugin({
pluginName: 'Base64ToGallery',
plugin: 'cordova-base64-to-gallery',
pluginRef: 'cordova',
repo: 'https://github.com/Nexxa/cordova-base64-to-gallery',
platforms: ['Android', 'iOS', 'Windows Phone 8']
})
@Injectable()
export class Base64ToGallery extends IonicNativePlugin {
/**
* Converts a base64 string to an image file in the device gallery
* @param {string} data The actual base64 string that you want to save
* @param {any} [options] An object with properties
* @returns {Promise} returns a promise that resolves when the image is saved.
*/
@Cordova({
successIndex: 2,
* constructor(private barcodeScanner: BarcodeScanner) { }
*
* ...
*
*
* this.barcodeScanner.scan().then(barcodeData => {
* console.log('Barcode data', barcodeData);
* }).catch(err => {
* console.log('Error', err);
* });
* ```
* @interfaces
* BarcodeScannerOptions
* BarcodeScanResult
*/
@Plugin({
pluginName: 'BarcodeScanner',
plugin: 'phonegap-plugin-barcodescanner',
pluginRef: 'cordova.plugins.barcodeScanner',
repo: 'https://github.com/phonegap/phonegap-plugin-barcodescanner',
platforms: ['Android', 'BlackBerry 10', 'Browser', 'iOS', 'Windows']
})
@Injectable()
export class BarcodeScanner extends IonicNativePlugin {
Encode: {
TEXT_TYPE: string;
EMAIL_TYPE: string;
PHONE_TYPE: string;
SMS_TYPE: string;
} = {
TEXT_TYPE: 'TEXT_TYPE',
EMAIL_TYPE: 'EMAIL_TYPE',
* subtitle: 'Choose an action',
* buttonLabels: buttonLabels,
* addCancelButtonWithLabel: 'Cancel',
* addDestructiveButtonWithLabel: 'Delete',
* androidTheme: this.actionSheet.ANDROID_THEMES.THEME_HOLO_DARK,
* destructiveButtonLast: true
* };
*
* this.actionSheet.show(options).then((buttonIndex: number) => {
* console.log('Button pressed: ' + buttonIndex);
* });
* ```
* @interfaces
* ActionSheetOptions
*/
@Plugin({
pluginName: 'ActionSheet',
plugin: 'cordova-plugin-actionsheet',
pluginRef: 'plugins.actionsheet',
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet',
platforms: ['Android', 'Browser', 'iOS', 'Windows', 'Windows Phone 8']
})
@Injectable()
export class ActionSheet extends IonicNativePlugin {
/**
* Convenience property to select an Android theme value
*/
ANDROID_THEMES: {
THEME_TRADITIONAL: number;
THEME_HOLO_DARK: number;
THEME_HOLO_LIGHT: number;
*
* let items = [{label: "Hello", number: "123"}];
* this.callDirectory.addIdentification(items)
* .then((res: any) => console.log(res))
* .catch((error: any) => console.error(error));
*
* this.callDirectory.reloadExtension()
* .then(res: string) => console.log(res))
* .catch((error: any) => console.error(error));
* ```
*
* @Interfaces
* CallDirectoryItem
* CallDirectoryLog
*/
@Plugin({
pluginName: 'CallDirectory',
plugin: 'cordova-plugin-call-directory',
pluginRef: 'CallDirectory',
repo: 'https://github.com/GEDYSIntraWare/cordova-plugin-call-directory',
install: 'cordova plugin add cordova-plugin-call-directory --variable EXT_NAME="Cordova-Directory" --variable ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES="NO"',
installVariables: ['EXT_NAME', 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'],
platforms: ['iOS']
})
@Injectable()
export class CallDirectory extends IonicNativePlugin {
/**
* Check if the call directory extension is available and enabled
* @return {Promise} Returns a promise with result
*/
@Cordova()