Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notification foreground listener preventing notification display #963

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

nan-li
Copy link
Contributor

@nan-li nan-li commented Jan 24, 2024

Description

One Line Summary

This PR fixes a bug that prevented notifications after the first one from displaying when the foreground listener is set.

Details

  • The notificationWillShowInForegoundCallbackId is set over the bridge when the developer calls to add their notification foreground listener.
  • It is used to link back to their listeners and fire them.
  • This callback ID was being overwritten once the first foreground notification is processed.
  • This led subsequent foreground notifications to be stuck and never display.

Motivation

Fixes #943

Scope

We were overwriting this notificationWillShowInForegoundCallbackId. It is set when app developers call the add listener method to add their listener, so it can hook back to their listener.

Testing

Manual testing

iPhone 13 on iOS 17.2

✅ All foreground notifications display if I did not call preventDefault()
✅ If multiple listeners are added, they are all triggered
✅ Listener calls preventDefault() and then display() 5 seconds later will display the notification after 5 seconds
✅ Listener calls preventDefault() and notification never displays

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

* The `notificationWillShowInForegoundCallbackId` is set over the bridge when the developer calls to add their notification foreground listener.
* It is used to link back to their listeners and fire them.
* This callback ID was being overwritten when the first foreground notification is processed.
* This led subsequent foreground notifications to be stuck.
@nan-li nan-li changed the title Fix notification foreground listener preventing subsequent notification displays Fix notification foreground listener preventing notification display Jan 24, 2024
@nan-li nan-li merged commit 9709129 into user_model/main Jan 29, 2024
3 checks passed
@nan-li nan-li deleted the fix_notification_foreground_listener branch January 29, 2024 18:38
@jennantilla jennantilla mentioned this pull request Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants