diff --git a/src/@ionic-native/core/plugin.ts b/src/@ionic-native/core/plugin.ts index f09f91ccfe..49b1281f75 100644 --- a/src/@ionic-native/core/plugin.ts +++ b/src/@ionic-native/core/plugin.ts @@ -152,11 +152,16 @@ function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any function wrapOtherPromise(pluginObj: any, methodName: string, args: any[], opts: any= {}) { return getPromise((resolve, reject) => { - let pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts); - if (pluginResult && pluginResult.error) { - reject(pluginResult.error); + const pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts); + if (pluginResult) { + if (pluginResult.error) { + reject(pluginResult.error); + } else if (pluginResult.then) { + pluginResult.then(resolve).catch(reject); + } + } else { + reject({ error: 'unexpected_error' }); } - pluginResult.then(resolve).catch(reject); }); }