-
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
Fixed Pre-existing Notification Delegate #924
Conversation
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 methods
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.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @jkasten2 and @tanaynigam)
iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 627 at r1 (raw file):
This swizzles in the OneSignal methods into the existing non-OneSignal delegate. */ curNotifCenter.delegate = curNotifCenter.delegate;
Nice find! @jkasten2 is there a way to unit test this on the native side?
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.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @emawby)
iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 627 at r1 (raw file):
Previously, emawby (Elliot Mawby) wrote…
Nice find! @jkasten2 is there a way to unit test this on the native side?
I see a test called testZSwizzling
which does something close to what we need to test here. However there is a comment on this there is test carry over. I think we could clean this up and make a working test with some work.
Since this PR is on the 2.x.x branch I think we should omit the test in this PR. We can focus on creating a test on the master branch PR when we create it.
iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 627 at r1 (raw file): Previously, jkasten2 (Josh Kasten) wrote…
Added tests to this PR on master: |
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @emawby)
This happens when another library's delegate is loaded before OneSignal's delegate code.
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.
OneSignal/OneSignal-Unity-SDK#245
This change is