-
Notifications
You must be signed in to change notification settings - Fork 262
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 pre-existing notification delegate #926
Merged
jkasten2
merged 8 commits into
master
from
fix/pre-existing_notification_delegate_for_master
May 18, 2021
Merged
Fix pre-existing notification delegate #926
jkasten2
merged 8 commits into
master
from
fix/pre-existing_notification_delegate_for_master
May 18, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Issue was that the DummyNotificationCenterDelegate was going out of scope and getting removed. - This created an issue where OneSignal swizzling was no longer wroking, which broke any notification open tests.
* Moved swizzling logic in setOneSignalUNDelegate into swizzleSelectorsOnDelegate - No logic changes just a move. * This cleans up code a bit and also makes it more testable.
* Added this method on a new helper to undo swizzling in test * This way there is zero carry over side-effects on other tests
* Moved this test into it's own testing file. - We will be adding more swizzling tests in (a) up comming commit(s)
* Moved registerAsUNNotificationCenterDelegate out of OneSignalHelper and into OneSignalUNUserNotificationCenter - This better encapsulates this logic * Added a new setup method that OneSignal class. - Before OneSignal had to call two methods which as client shouldn't have to know or care about it at that level.
* OneSignal is normally loaded into memory and it performs swizzling before any code is exlcude as it happens in +load. This is not always the case however so this simulates so other code winning the setDelegate race. * Added putIntoPreloadedState helper to simulate OneSignal class not being loaded into memory yet.
* This happens when another library's delegate is loaded before OneSignal's delegate code. * This commit solves it by reassigning the pre loaded delegate to swizzle in OneSignal's logic
* Updated the comment to better fit what we added in the else statement from our last commit.
emawby
approved these changes
May 13, 2021
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.
Reviewed 1 of 1 files at r1, 2 of 2 files at r2, 3 of 3 files at r3, 2 of 2 files at r4, 6 of 6 files at r5.
Reviewable status: 5 of 9 files reviewed, all discussions resolved (waiting on @emawby and @tanaynigam)
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This fixes an issue where OneSignal's notification open event would not fire if a UNUserNotificationCenterDelegate was assigned before the OneSignal was loaded into memory.
Details
This commit solves it by reassigning the pre-loaded delegate into swizzle in OneSignal's methods.
This issue was discovered through a Unity issue where Unity Mobile Notification Services would load their delegate before OneSignal's delegate.
Tests
Related PR
This applies the same fix from PR #924 but includes some refactoring to make it testable.
This change is