Repository navigation
fix: [SDK-5698] let Initialize and Login reach native on Android - #918
abdulraqeeb33 wants to merge 3 commits into
Conversation
Android native now takes a nullable appId and externalId and logs and returns, so the wrapper guard only gets in the way. Returning early from Initialize was the damaging one: native falls back to the cached app id, and short-circuiting skipped that fallback, leaving the SDK unstarted so the next Login threw IllegalStateException. The iOS implementation keeps both guards, and they are now load-bearing rather than redundant. OneSignalUnityBridge.mm forwards straight to [OneSignal login:], which passes externalId into a non-optional Swift parameter with no nil handling. Both sites gained a comment, because they otherwise read as leftover duplication. Scope is only these two methods. The alias, email, SMS, tag, trigger, and outcome guards stay on both platforms: those native parameters are still non-null. DO NOT MERGE until OneSignalAndroidDependencies.cs can be bumped to a release containing the never-crash change. It pins 5.11.0, where initWithContext and login take non-null Kotlin parameters, so a null would reach them and throw NullPointerException. Co-authored-by: Cursor <cursoragent@cursor.com>
| if (InputGuard.IsMissing(appId, "initialize: appId")) | ||
| return; |
There was a problem hiding this comment.
Non-blocking: with this guard gone, _completedInit(appId) at the end of Initialize now runs when appId is null or "". It sets OneSignalPlatform.AppId to that and fires OnInitialize(null), so the attribution hook sends a null app id. Maybe skip _completedInit when appId is missing?
There was a problem hiding this comment.
Real gap, not fixed. Holding with the rest of the set until the flag rollout, so it gets done once rather than patched blind.
There was a problem hiding this comment.
Now fixed in 0cfd95f. _completedInit only runs when the app id is non-empty, so OnInitialize no longer gets a value the SDK is not using.
| // The iOS bridge forwards straight to [OneSignal initialize:], whose externalId | ||
| // counterpart reaches a non-optional Swift parameter. Null has to stop here. |
There was a problem hiding this comment.
Nit: this gives the login/Swift reason, but iOS initialize: handles nil and falls back to the cached app id. The real reasons are symmetry with Login and rejecting "". Could the comment say that instead?
There was a problem hiding this comment.
Fixed in 0965bfc. The comment now says initialize: handles nil and it is "" that gets rejected without falling back.
Native initialize: handles nil; it is the empty string it rejects without falling back to the cached app id. The previous comment borrowed Login's non-optional Swift reasoning, which does not apply here. Review feedback from fadi-george on #918. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Comment reason fixed in 0965bfc: native
|
With the guard gone, _completedInit ran for a null or empty appId, setting OneSignalPlatform.AppId to it and firing OnInitialize with a value the SDK is not actually using. Native may have resolved a cached app id instead. Review feedback from fadi-george on #918. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Follow-up: the |
|
@abdulraqeeb33 please fix the title |
Important
Blocked on the never-crash rollout, not just an AAR/version bump. See "Why this cannot merge yet" below. Native's never-crash behavior sits behind
SDK_NEVER_CRASH_ENABLED, which defaults to off, and the legacy path still throws on a null.Description
One Line Summary
Remove input validation that was added to the wrapper by mistake, so the native SDK owns it.
Details
Motivation: this undoes a wrapper-side mistake
SDK-5327 added null and empty checks to every client SDK at once, wrappers included. For most APIs that was harmless duplication. For
initializeandloginit was the wrong layer, and it caused a bug.Validation belongs in the native SDK. It is the only layer that knows what an invalid input should actually do, and duplicating it per wrapper means six implementations drifting from each other and from native. The wrapper's job is to pass the call through.
initializeshows why this matters concretely. Native falls back to the app ID cached by an earlier launch when the one it is given is unusable. The wrapper guard returned before native was ever called, so that fallback never ran, the SDK stayed unstarted, and the nextloginfailed. The wrapper was not preventing a bug, it was creating one. That is the SDK-5366 chain, and the fix is to delete the guard rather than to catch the symptom downstream.So this PR is a correction, not a feature: the check should have gone into native in the first place.
Why this cannot merge yet
Native Android's never-crash behavior is behind a remote feature flag, and it is off by default:
When the flag is off,
NeverCrashKillSwitch.create()returns the legacyOneSignalImp, which still throws by design:The helper is commented "The kill switch's fallback keeps the crash a Java null used to hit in the non-null facade." The nullable signatures from #2841 are real, but the log-and-ignore behavior behind them only applies on the V2 path.
So merging needs both:
SDK_NEVER_CRASH_ENABLEDactually rolled out, since the flag is evaluated per app from mirrored startup flags.Until then, removing the guard reintroduces exactly the SDK-5304 crash for every app the flag has not reached. My original description claimed Android already logs and ignores a null; that was wrong, and it was wrong in the same way across all six wrapper PRs.
Scope
Only
InitializeandLogin, and only inOneSignalAndroid.cs.The alias, email, SMS, tag, trigger, and outcome guards stay on both platforms. Those native parameters are still non-null.
Why the iOS guards stay
OneSignaliOS.cskeeps both guards, and they changed from redundant duplication to load-bearing.OneSignalUnityBridge.mmforwards straight through:Native iOS
login:passesexternalIdinto a non-optional Swift parameter with no nil handling, so a null has to stop in the wrapper. Both sites gained a comment, since they otherwise read as leftover duplication that a future cleanup would delete.(iOS
initialize:does handle nil and falls back to the cached app id, but the guard is kept there for symmetry withLoginand because the empty-string case still needs rejecting.)Testing
Unit testing
None. The change only removes two early returns; this repo has no unit test project covering the platform bridges.
Manual testing
Not exercised on a device, and it cannot be meaningfully exercised until the dependency bump: on the pinned
5.11.0, a null still reaches non-null Kotlin parameters.Affected code checklist
Checklist
Overview
Testing
Final pass