From c6a7ae617fb27b9cdf93e948d71b697c5f1f7cdb Mon Sep 17 00:00:00 2001 From: Martijn Swart Date: Wed, 26 Jun 2019 21:04:08 +0200 Subject: [PATCH 1/2] [web] Added support for visibilitychange event --- core/src/web/app.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/web/app.ts b/core/src/web/app.ts index 57ab63a5f6..d3ebbf3ec7 100644 --- a/core/src/web/app.ts +++ b/core/src/web/app.ts @@ -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; }> { @@ -25,6 +27,14 @@ export class AppPluginWeb extends WebPlugin implements AppPlugin { getLaunchUrl(): Promise { return Promise.resolve({ url: '' }); } + + handleVisibilityChange():void { + const data = { + isActive: document.hidden !== true + }; + + this.notifyListeners('appStateChange', data); + } } const App = new AppPluginWeb(); From fdfef33adbe809ce2906a83367331b8b473ff8fa Mon Sep 17 00:00:00 2001 From: Martijn Swart Date: Tue, 10 Mar 2020 22:56:24 +0100 Subject: [PATCH 2/2] fix(android): make sure scheduled time is shown in localnotifications (#2325) See #2325 --- .../plugin/notification/LocalNotificationManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java index 2e095269f9..9d0b18d97a 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java @@ -170,6 +170,12 @@ private void buildNotification(NotificationManagerCompat notificationManager, Lo mBuilder.setGroup(group); } + // make sure scheduled time is shown instead of display time + if (localNotification.isScheduled()) { + mBuilder.setWhen(localNotification.getSchedule().getAt().getTime()) + .setShowWhen(true); + } + mBuilder.setVisibility(Notification.VISIBILITY_PRIVATE); mBuilder.setOnlyAlertOnce(true);