From 05962d2c19c3973c8884545b1300c3250221c26d Mon Sep 17 00:00:00 2001 From: Niklas Date: Sun, 1 Oct 2017 19:46:17 +0200 Subject: [PATCH] fix(indexappcontent): Return observable for onItemPressed --- .../plugins/index-app-content/index.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/@ionic-native/plugins/index-app-content/index.ts b/src/@ionic-native/plugins/index-app-content/index.ts index 9b492df21f..389aa8a32b 100644 --- a/src/@ionic-native/plugins/index-app-content/index.ts +++ b/src/@ionic-native/plugins/index-app-content/index.ts @@ -1,5 +1,8 @@ import { Injectable } from '@angular/core'; import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; + +declare var window: any; export interface IndexItem { domain: string; @@ -95,12 +98,18 @@ export class IndexAppContent extends IonicNativePlugin { /** * If user taps on a search result in spotlight then the app will be launched. * You can register a Javascript handler to get informed when this happens. - * @param {IndexItem} Clicked Item - * @return {Promise} Returns promise + * @returns {Observable} returns an observable that notifies you when he user presses on the home screen icon */ @Cordova() - onItemPressed(payload: IndexItem) { - return; + onItemPressed(): Observable { + return new Observable(observer => { + if (window.plugins.indexAppContent) { + window.plugins.indexAppContent.onItemPressed = observer.next.bind(observer); + } else { + observer.error('Index-App-Content plugin is not available.'); + observer.complete(); + } + }); } /**