From cb14978199c087046d7783a7f779d18e9eb86209 Mon Sep 17 00:00:00 2001 From: Gaven Henry Date: Wed, 29 Apr 2020 10:27:03 +0800 Subject: [PATCH] Move clearAllNotifications from pause to destroy Notifications should persist when the app is moved to the background in order to draw the user back to re-activate the app when they are done multitasking. Notifications should be destroyed when the all is closed though to avoid clutter. This should also resolve: https://github.com/ghenry22/cordova-plugin-music-controls2/issues/7 --- src/android/com/adobe/phonegap/push/PushPlugin.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/android/com/adobe/phonegap/push/PushPlugin.java b/src/android/com/adobe/phonegap/push/PushPlugin.java index c1f0a10c6..8bec730d5 100644 --- a/src/android/com/adobe/phonegap/push/PushPlugin.java +++ b/src/android/com/adobe/phonegap/push/PushPlugin.java @@ -510,12 +510,6 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) { public void onPause(boolean multitasking) { super.onPause(multitasking); gForeground = false; - - SharedPreferences prefs = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, - Context.MODE_PRIVATE); - if (prefs.getBoolean(CLEAR_NOTIFICATIONS, true)) { - clearAllNotifications(); - } } @Override @@ -529,6 +523,12 @@ public void onDestroy() { super.onDestroy(); gForeground = false; gWebView = null; + + SharedPreferences prefs = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, + Context.MODE_PRIVATE); + if (prefs.getBoolean(CLEAR_NOTIFICATIONS, true)) { + clearAllNotifications(); + } } private void clearAllNotifications() {