Skip to content

Commit

Permalink
fix(web): support for App 'appStateChange' event (#1715)
Browse files Browse the repository at this point in the history
  • Loading branch information
naranjamecanica authored and jcesarmobile committed Jun 28, 2019
1 parent afc6d7e commit 80cd214
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/src/web/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ export class AppPluginWeb extends WebPlugin implements AppPlugin {
name: 'App',
platforms: ['web']
});

document.addEventListener('visibilitychange', this.handleVisibilityChange.bind(this), false);
}

exitApp(): never {
throw new Error("Method not implemented.");
throw new Error('Method not implemented.');
}

canOpenUrl(_options: { url: string; }): Promise<{ value: boolean; }> {
Expand All @@ -25,6 +27,14 @@ export class AppPluginWeb extends WebPlugin implements AppPlugin {
getLaunchUrl(): Promise<AppLaunchUrl> {
return Promise.resolve({ url: '' });
}

handleVisibilityChange():void {
const data = {
isActive: document.hidden !== true
};

this.notifyListeners('appStateChange', data);
}
}

const App = new AppPluginWeb();
Expand Down

0 comments on commit 80cd214

Please sign in to comment.