[Fix] Prevent re-swizzling when there is another swizzler #1100
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.
Description
One Line Summary
Prevent infinite loops between OneSignal and other SDKs that also swizzle.
Details
Motivation
After a recent swizzling change (commit hasn't gotten into a release yet) it was discovered that it introduced a bug with FlutterFire which causes an infinite loop between the two with the
AppDelegate
. This is due to the factFlutterFire
clears theAppDelegate
and re-assigns it and OneSignal re-swizzles it self back. Then when anAppDelegate
selector fires from iOS OneSignal and FlutterFire call each other in a loop due to this.Scope
Effects swizzling for both
AppDelegate
andUNUserNotificationCenterDelegate
.Testing
Unit testing
Added a unit test that reproduced the exact FlutterFire issue.
Manual testing
Ensured issue no longer happens on the Flutter project with FlutterFire and OneSignal. Tested on an iPhone 6s with iOS 14.4.1 and sent a notification while the app was in the foreground, ensured "onesignalUserNotificationCenter:willPresentNotification:withCompletionHandler: Fired!" was printed to the log.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is