-
Notifications
You must be signed in to change notification settings - Fork 370
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
[User Model] Rename notification event listeners #1765
Conversation
* Make all notification listeners 0:* (some were 0:1) * Renamed all "handlers" to be either a "listener" or an "observer" depending on their purpose. All callbacks now have pattern "onXXXXXX" for each callback. * Use the terminology "click" instead of "open". * Add IEventNotifier.hasSubscribers to determine if there are subscribers. A few implementing classes had to add this. * Replaced `complete()` pattern with `preventDefault()` pattern in NSE notification received callback and foreground onWillDisplay callback. * Add IDisplayableNotification and IDisplayableMutableNotification which adds a `display()` function to an INotification. This allows the manual display of a notification, when `event.preventDefault()` is called. * Internally, rework NotificationGenerationProcessor to accommodate `preventDefault` pattern. The notification is now constructed when the notification job is constructed and is never copied/altered until the end of its lifecycle. * Update example application for new naming conventions and patterns. * Update for new naming conventions and patterns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had only a few nits that don't need to block this PR; however, a few points need to be addressed before I'm comfortable approving this. The note about the log should be applied to all files that make use of the format I specified although I only called it out once (this is my style in PR review to call something our once and avoid beating a dead 🐴 )
Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application/MainApplication.java
Outdated
Show resolved
Hide resolved
Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application/MainApplication.java
Outdated
Show resolved
Hide resolved
Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application/MainApplication.java
Outdated
Show resolved
Hide resolved
...DK/onesignal/core/src/main/java/com/onesignal/notifications/INotificationServiceExtension.kt
Outdated
Show resolved
Hide resolved
...lDemo/app/src/main/java/com/onesignal/sdktest/notification/NotificationServiceExtension.java
Outdated
Show resolved
Hide resolved
...gnalSDK/onesignal/core/src/main/java/com/onesignal/notifications/INotificationClickResult.kt
Outdated
Show resolved
Hide resolved
* in order to receive control during the lifecycle of the notification. This handler will *only* receive | ||
* control when the application is in the foreground when the notification is received. | ||
* | ||
* @see [Foreground Notification Received Event | OneSignal Docs](https://documentation.onesignal.com/docs/sdk-notification-event-handlers#foreground-notification-received-event) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use our v11 docs which are here: https://dash.readme.com/project/onesignal/v11.0/docs/sdk-notification-event-handlers
Note that no one has provided a thorough review of these docs, and they may be wildly inaccurate or even incomplete.
...K/onesignal/core/src/main/java/com/onesignal/notifications/INotificationLifecycleListener.kt
Outdated
Show resolved
Hide resolved
...K/onesignal/core/src/main/java/com/onesignal/notifications/INotificationLifecycleListener.kt
Outdated
Show resolved
Hide resolved
...alSDK/onesignal/core/src/main/java/com/onesignal/notifications/INotificationReceivedEvent.kt
Outdated
Show resolved
Hide resolved
…cations/IDisplayableNotification.kt Co-authored-by: William Shepherd <williamrshepherd@gmail.com>
…cations/INotificationClickResult.kt Co-authored-by: William Shepherd <williamrshepherd@gmail.com>
…cations/INotificationLifecycleListener.kt Co-authored-by: William Shepherd <williamrshepherd@gmail.com>
…cations/INotificationServiceExtension.kt Co-authored-by: William Shepherd <williamrshepherd@gmail.com>
…cations/IDisplayableNotification.kt Co-authored-by: William Shepherd <williamrshepherd@gmail.com>
@iAmWillShepherd pushed up changes. Please let me know if you have additional feedback! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚢
Could you share your thought process on which term to use? At the moment, it's not clear what you mean by their purpose. |
Realizing these terms are fuzzy in general, this is based on our team discussions to define as:
|
[User Model] Rename notification event listeners
[User Model] Rename notification event listeners
[User Model] Rename notification event listeners
Description
One Line Summary
Rename notification event listeners based on new naming convention.
Details
complete()
pattern withpreventDefault()
pattern in NSE notification received callback and foreground onWillDisplay callback.display()
function to an INotification. This allows the manual display of a notification, whenevent.preventDefault()
is called.preventDefault
pattern. The notification is now constructed when the notification job is constructed and is never copied/altered until the end of its lifecycle.Motivation
A desire to align terminologies and naming conventions across the OneSignal SDKs.
Scope
This change is primarily a name change within the
notifications
module/namespace. There are some functional changes related to notification generation processing due to a programming pattern change (i.e. change from usingcomplete()
to usingpreventDefault()
).Testing
Unit testing
Existing unit tests related to notification generation were updated to new expected behavior. Mostly this involved adding new mock calls that were previously not required.
Manual testing
Ran the example app with both a NSE and a foreground lifecycle listener, checking for different variations and manually inspecting behavior:
event.preventDefault()
and returns immediately -> Notification does not showevent.preventDefault()
then sleeps for 40 seconds before returning -> Notification shows after 30 seconds.event.notification.setExtender
and alters the notification via extender -> Notification is shown, alteredevent.preventDefault()
then starts a thread which callsevent.notification.display()
after 10 seconds -> Notification shows after 10 seconds.event.preventDefault()
then starts a thread which callsevent.notification.display()
after 40 seconds -> Notification does not show.event.preventDefault()
and returns immediately -> Notification does not showevent.preventDefault()
then sleeps for 40 seconds before returning -> Notification shows after 30 seconds.event.preventDefault()
then starts a thread which callsevent.notification.display()
after 10 seconds -> Notification shows after 10 seconds.event.preventDefault()
then starts a thread which callsevent.notification.display()
after 40 seconds -> Notification does not show.I also confirmed the notification clicked listener and permission observer for appropriate behavior, though these were just name changes.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is