Skip to content

Commit f3f6f2b

Browse files
committed
not firing willShowInForegroundHandler for restoring notifications
1 parent 1eec169 commit f3f6f2b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationBundleProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private static int processJobForDisplay(OSNotificationController notificationCon
146146

147147
if (doDisplay) {
148148
androidNotificationId = notificationJob.getAndroidId();
149-
if (fromBackgroundLogic && OneSignal.shouldFireForegroundHandlers()) {
149+
if (fromBackgroundLogic && OneSignal.shouldFireForegroundHandlers(notificationJob)) {
150150
notificationController.setFromBackgroundLogic(false);
151151
OneSignal.fireForegroundHandlers(notificationController);
152152
// Notification will be processed by foreground user complete or timer complete

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ static void handleNotificationReceived(OSNotificationGenerationJob notificationJ
22992299
* <br/><br/>
23002300
* @see OSNotificationWillShowInForegroundHandler
23012301
*/
2302-
static boolean shouldFireForegroundHandlers() {
2302+
static boolean shouldFireForegroundHandlers(OSNotificationGenerationJob notificationJob) {
23032303
if (!isInForeground()) {
23042304
OneSignal.onesignalLog(LOG_LEVEL.INFO, "App is in background, show notification");
23052305
return false;
@@ -2310,6 +2310,12 @@ static boolean shouldFireForegroundHandlers() {
23102310
return false;
23112311
}
23122312

2313+
// Notification is restored. Don't fire for restored notifications.
2314+
if (notificationJob.isRestoring()) {
2315+
OneSignal.onesignalLog(LOG_LEVEL.INFO, "Not firing notificationWillShowInForegroundHandler for restored notifications");
2316+
return false;
2317+
}
2318+
23132319
return true;
23142320
}
23152321

0 commit comments

Comments
 (0)