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

Fixed Pre-existing Notification Delegate #924

Merged
merged 1 commit into from
May 14, 2021

Conversation

tanaynigam
Copy link
Contributor

@tanaynigam tanaynigam commented May 12, 2021

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 Reviewable

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
Copy link
Contributor

@emawby emawby left a 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?

Copy link
Member

@jkasten2 jkasten2 left a 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.

@jkasten2
Copy link
Member


iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 627 at r1 (raw file):

Previously, jkasten2 (Josh Kasten) wrote…

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.

Added tests to this PR on master:
#926

Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @emawby)

@jkasten2 jkasten2 merged commit 1bf1d7b into sdk_2.X.X May 14, 2021
@jkasten2 jkasten2 deleted the fix/pre-existing_notification_delegate branch May 14, 2021 20:16
@jkasten2 jkasten2 mentioned this pull request May 14, 2021
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.

3 participants