Use AngularJS promise if available

This commit is contained in:
Ibby Hadeed
2017-12-29 10:15:44 -05:00
parent fc9dcc8e64
commit 0cc1a2b2ff
8 changed files with 64 additions and 49 deletions
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { IonicNativePlugin, Plugin } from '@ionic-native/core';
import { IonicNativePlugin, Plugin, getPromise } from '@ionic-native/core';
declare const navigator: any;
@@ -42,7 +42,7 @@ export class Screenshot extends IonicNativePlugin {
* @returns {Promise<any>}
*/
save(format?: string, quality?: number, filename?: string): Promise<any> {
return new Promise<any>(
return getPromise<any>(
(resolve, reject) => {
navigator.screenshot.save(
(error: any, result: any) => {
@@ -68,7 +68,7 @@ export class Screenshot extends IonicNativePlugin {
* @returns {Promise<any>}
*/
URI(quality?: number): Promise<any> {
return new Promise<any>(
return getPromise<any>(
(resolve, reject) => {
navigator.screenshot.URI(
(error: any, result: any) => {