fix(ios): forward every application delegate assignment - #1979
Merged
fadi-george merged 2 commits intoSep 1, 2026
Merged
Conversation
Gating injection on a single dispatch_once token bound the launch hook to the first non-null delegate class. Now that every assignment is forwarded, a later delegate of a different class became active without the hook, so initOneSignal: was skipped at launch. Track injected classes instead so each new delegate class is injected exactly once. Co-authored-by: Cursor <cursoragent@cursor.com>
fadi-george
force-pushed
the
codex/onesignal-ios-delegate-assignment
branch
from
August 31, 2026 23:24
8679d1f to
cd6ef37
Compare
fadi-george
approved these changes
Aug 31, 2026
Merged
This file contains hidden or 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
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.
Description
One Line Summary
Forward every application delegate assignment to
UIApplication, and install the launch hook once per delegate class instead of once per process.Compatibility and observable changes
Setting a replacement delegate or clearing it with
nilnow reachesUIApplicationas expected. A leadingnildelegate no longer consumes the installation token.Because assignments are no longer swallowed, a replacement delegate genuinely becomes active. Installation is therefore keyed on the delegate class rather than a single process-wide token, so a later delegate of a different class still gets the launch hook. Each class is injected at most once, since a second
method_exchangeImplementationswould swap the original implementation back and drop OneSignal out of the launch chain.Apps that today rely on the old behavior of silently discarding a
nilor replacement delegate assignment will now see that assignment take effect, which matches theUIApplicationcontract.Details
Motivation
The source audit reproduced the failure paths described below. This PR contains only the associated fix; unrelated audit changes are in separate PRs.
Two defects existed. Only the first assignment ever reached
UIApplication, so replacements andnilclears were dropped. And a leadingnilconsumed thedispatch_oncetoken, leaving the app with no delegate and OneSignal never initialized.Scope
ios/RCTOneSignal/UIApplication+RCTOnesignal.mNot changed:
injectSelectorand theoneSignalApplication:didFinishLaunchingWithOptions:chaining guard. A delegate class that inherits rather than implementsapplication:didFinishLaunchingWithOptions:still has that inherited implementation shadowed and not chained. That behavior is identical before and after this PR and is tracked separately.Testing
Compiled real category code with Foundation/Objective-C runtime and UIApplication/delegate doubles; baseline replacement and clearing fail, and all three assignment checks pass fixed.
Each code/tooling fix was also applied independently to upstream commit
a70312207cf094ac361eaa9196c317acb175c2cdand passed its targeted external actual-source diagnostics. Documentation snippets were checked separately. Native diagnostic harnesses use bridge/SDK doubles and are not an end-to-end push test.Per-class installation follow-up commit
The real category source was compiled unmodified against Foundation plus
UIApplication, delegate, andRCTOneSignaldoubles, with each scenario run in a fresh process so thedispatch_oncetoken starts clean. Three versions were compared: basea703122, the first commit, and the per-class commit.Also run:
clang -Wall -Wextrawith no warnings,clang-formatLLVM style clean, existing SDK suite of 263 tests passing, and a Debug iOS Simulator build of thedemoexample reaching** BUILD SUCCEEDED **. The build log was checked to confirmUIApplication+RCTOnesignal.mrecompiled forarm64andx86_64in thereact-native-onesignalpod target rather than being served from cache.On the combined audit branch:
vp check: formatting, lint and type checks pass; native Spotless check passes.No checked-in test files were added or modified; regression evidence comes from external diagnostic harnesses and the existing suite. No physical-device, live notification delivery, Appium/BrowserStack, or release-workflow execution is claimed. The no-location example's stale native lock was updated locally to resolve the current SDK for verification; generated locks are not part of this PR.
Affected code checklist
Checklist