How to use the @ionic-native/core.getPromise function in @ionic-native/core

To help you get started, we’ve selected a few @ionic-native/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / ionic-native-google-maps / src / @ionic-native / plugins / google-maps / index.ts View on Github external
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();
          }
        });
      });
    }
  }
github ionic-team / ionic-native-google-maps / src / @ionic-native / plugins / google-maps / index.ts View on Github external
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;
github ionic-team / ionic-native-google-maps / src / @ionic-native / plugins / google-maps / index.ts View on Github external
addGroundOverlay(options: GroundOverlayOptions): Promise {
    return getPromise((resolve, reject) => {
      this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => {
        if (groundOverlay) {
          const overlayId: string = groundOverlay.getId();
          const overlay = new GroundOverlay(this, groundOverlay);
          this.get('_overlays')[overlayId] = overlay;
          groundOverlay.one(overlayId + '_remove', () => {
            if (this.get('_overlays')) {
              this.get('_overlays')[overlayId] = null;
              overlay.destroy();
            }
          });
          resolve(overlay);
        } else {
          reject();
        }
      });
github ionic-team / ionic-native-google-maps / src / @ionic-native / plugins / google-maps / index.ts View on Github external
addKmlOverlay(options: KmlOverlayOptions): Promise {
    return getPromise((resolve, reject) => {
      this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => {
        if (kmlOverlay) {
          const overlayId: string = kmlOverlay.getId();
          const overlay = new KmlOverlay(this, kmlOverlay);
          this.get('_overlays')[overlayId] = overlay;
          kmlOverlay.one(overlayId + '_remove', () => {
            if (this.get('_overlays')) {
              this.get('_overlays')[overlayId] = null;
              overlay.destroy();
            }
          });
          resolve(overlay);
        } else {
          reject();
        }
      });
github ionic-team / ionic-native / src / @ionic-native / plugins / secure-storage / index.ts View on Github external
create(store: string): Promise {
    return getPromise((res: Function, rej: Function) => {
      const instance = new (SecureStorage.getPlugin())(
        () => res(new SecureStorageObject(instance)),
        rej,
        store
      );
    });
  }
}
github ionic-team / ionic-native-google-maps / src / @ionic-native / plugins / google-maps / index.ts View on Github external
forEachAsync(fn: ((element: T, callback: () => void) => void)): Promise {
    return getPromise((resolve) => {
      this._objectInstance.forEach(fn, resolve);
    });
  }
github ionic-team / ionic-native / src / @ionic-native / plugins / contacts / index.ts View on Github external
pickContact(): Promise {
    return getPromise((resolve: Function, reject: Function) => {
      navigator.contacts.pickContact(
        (contact: any) => resolve(processContact(contact)),
        reject
      );
    });
  }
}
github ionic-team / ionic-native-google-maps / src / @ionic-native / plugins / google-maps / index.ts View on Github external
one(eventName: string): Promise {
    return getPromise((resolve) => {
      this._objectInstance.one(eventName, (...args: any[]) => {
        const newArgs = normalizeArgumentsOfEventListener.call(this, this._objectInstance, args);
        resolve(newArgs);
      });
    });
  }
github ionic-team / ionic-native / src / @ionic-native / plugins / email-composer / index.ts View on Github external
hasClient(app?: string): Promise {
    return getPromise((resolve) => {
      if (app) {
        EmailComposer.getPlugin().hasClient(app, (result: boolean) => {
          if (result) {
            resolve(true);
          } else {
            resolve(false);
          }
        });
      } else {
        EmailComposer.getPlugin().getClients((apps: string[]) => {
          resolve(apps.length && apps.length > 0);
        });
      }
    });
  }
github ionic-team / ionic-native / src / @ionic-native / plugins / wonderpush / index.ts View on Github external
wrap(functionName: string, args: any[]): Promise {
    const plugin = WonderPush.getPlugin();
    const userPreferences = plugin ? plugin.UserPreferences : null;
    if (!plugin || !userPreferences || !userPreferences[functionName]) {
      return getPromise((res, rej) => {
        rej(new Error('Could not find plugin'));
      });
    }
    return getPromise((res, rej) => {
      userPreferences[functionName].apply(userPreferences, [ ...args, res]);
    });
  }