Skip to content

Commit

Permalink
Merge pull request OneSignal#1403 from OneSignal/fix/foregroundHandle…
Browse files Browse the repository at this point in the history
…r_on_restoring_notifs

No longer firing willShowInForegroundHandler for restoring notifications
emawby authored Aug 5, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 37c3a42 + f3f6f2b commit 09b8d91
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ private static int processJobForDisplay(OSNotificationController notificationCon

if (doDisplay) {
androidNotificationId = notificationJob.getAndroidId();
if (fromBackgroundLogic && OneSignal.shouldFireForegroundHandlers()) {
if (fromBackgroundLogic && OneSignal.shouldFireForegroundHandlers(notificationJob)) {
notificationController.setFromBackgroundLogic(false);
OneSignal.fireForegroundHandlers(notificationController);
// Notification will be processed by foreground user complete or timer complete
Original file line number Diff line number Diff line change
@@ -2299,7 +2299,7 @@ static void handleNotificationReceived(OSNotificationGenerationJob notificationJ
* <br/><br/>
* @see OSNotificationWillShowInForegroundHandler
*/
static boolean shouldFireForegroundHandlers() {
static boolean shouldFireForegroundHandlers(OSNotificationGenerationJob notificationJob) {
if (!isInForeground()) {
OneSignal.onesignalLog(LOG_LEVEL.INFO, "App is in background, show notification");
return false;
@@ -2310,6 +2310,12 @@ static boolean shouldFireForegroundHandlers() {
return false;
}

// Notification is restored. Don't fire for restored notifications.
if (notificationJob.isRestoring()) {
OneSignal.onesignalLog(LOG_LEVEL.INFO, "Not firing notificationWillShowInForegroundHandler for restored notifications");
return false;
}

return true;
}

0 comments on commit 09b8d91

Please sign in to comment.