fix: [SDK-5336] reuse matching default Firebase app - #2762
Conversation
There was a problem hiding this comment.
Multi-model review (Opus 5.5, GPT 5.6 Sol, Grok 4.7)
Threshold: 23 files, +1461/−69 = 1530 (no generated/lock/vendor/snapshots).
SDK-5336’s dual-field match for legacy default-app reuse looks correct: a token is not minted from a default app whose gcmSenderId or applicationId project number disagrees with the resolved sender.
Act on (2/3)
- FID mode still trusts
gcmSenderIdalone (firebaseAppSenderId). The same contradictory options that fail legacy reuse are accepted and registered; the new test pins that. The comment aboveinstallationIdRegistrationsays sender, app id, and API key must be one project. -32/-33are not retryable.PushTokenManagerstarts each process withpushToken = null, so a tokenless permanent FID error overwrites a persistedSUBSCRIBEDaddress. Same-instance tests hide this.
Consider
- Reuse does not require
projectId/apiKey; a matching-but-unusable default has no fallback (Opus). - App choice is not persisted, so late programmatic
FirebaseAppinit can flip tokens across sessions (Opus). onRegisteredstill does not refresh a rotated FID (GPT; carry-forward).
Noted: warn on a missing default app (normal for the gms flavor); shared default-app token isolation. Dismissed: no-fallback-after-match as a blocker (stated contract); ERROR(9999) mapping as a new regression (lone Grok, documented).
Sent by Cursor Automation: PR Reviews
|
|
||
| internal object FCMTokenProvider { | ||
| fun firebaseAppSenderId( | ||
| senderId: String?, |
There was a problem hiding this comment.
FID sender resolution returns gcmSenderId even when applicationId's project number disagrees. Legacy reuse rejects that pair (FCMLegacyAppSelector.matches). The new test does not apply legacy application id matching to installation id mode then registers that contradictory default app and uploads its installation id. validateSenderId only compares this derived sender, so the mismatch never becomes INVALID_FCM_SENDER_ID.
There was a problem hiding this comment.
This test is the isolation this PR is for. FID cannot fall back to ONESIGNAL_SDK_FCM_APP_NAME: installationIdRegistration says that app pairs the customer sender with OneSignal's shared credentials. firebaseAppSenderId returning gcmSenderId is the existing FID check, and this change does not touch it. A contradictory applicationId stays on the host default app on purpose.
There was a problem hiding this comment.
Confirmed, but this is existing FID behavior on the base branch. SDK-5336 intentionally leaves FID unchanged, so this is out of scope here.
Co-authored-by: Cursor <cursoragent@cursor.com>
cb6927d to
a10e48c
Compare
|
Checked the review findings:
|
abdulraqeeb33
left a comment
There was a problem hiding this comment.
Legacy default-app reuse matches on both gcmSenderId and the applicationId project number, and FID stays on the host default app.
Co-authored-by: Cursor <cursoragent@cursor.com>
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)21/21 touched executable lines covered (100.0% — requires ≥ 80%) |


Description
One Line Summary
Reuse a conclusively matching default Firebase app for legacy FCM token registration.
Details
Motivation
Preserve the customer's existing FCM token and update the same OneSignal subscription when migrating to OneSignal, while retaining the named OneSignal Firebase app as the safe fallback.
Scope
Legacy FCM-token mode now reuses an already initialized default Firebase app only when both
gcmSenderIdand the project number parsed fromapplicationIdmatch the resolved sender ID. Missing, malformed, contradictory, or mismatched defaults continue throughONESIGNAL_SDK_FCM_APP_NAMEand emit a warning. FID mode and arbitrary token-request failure behavior are unchanged.Testing
Unit testing
Added coverage for matching, programmatic, absent, malformed, contradictory, and mismatched Firebase configurations; runtime token failures; FID isolation; and updating an existing subscription after token changes.
Automated checks:
Manual testing
Not run on a physical device; behavior is covered by Robolectric/unit tests and a release build.
Affected code checklist
Checklist
Overview
Testing
Final pass