refactor: route identifier reads through OneSignalIdentifiers#1667
Open
nan-li wants to merge 5 commits into
Open
refactor: route identifier reads through OneSignalIdentifiers#1667nan-li wants to merge 5 commits into
nan-li wants to merge 5 commits into
Conversation
Add OneSignalIdentifiers in OneSignalOSCore with storedAppId and storedSubscriptionId accessors backed by shared UserDefaults. Migrate six call sites; drop the now-dead OSUD_APP_ID write to initStandard.
OSSubscriptionModel.subscriptionId.didSet already persists to UserDefaults on every change, so the static _pushSubscriptionId cache and its setter were duplicating state with drift risk. Route the one caller through OneSignalIdentifiers.subscriptionId directly. Drop the now-unused OSUserExecutor.setPushSubscriptionId call too — the model hydration on the line above already triggers the persistence path.
eb1a421 to
16a42e3
Compare
…gnalIdentifiers.currentAppId OneSignalConfigManager held two distinct things in one ObjC class in OneSignalCore: (1) the in-memory app_id state, and (2) the SDK-readiness predicate `shouldAwaitAppIdAndLogMissingPrivacyConsent`. Split into two Swift classes in OneSignalOSCore so all identifier accessors live in one module: - `OneSignalIdentifiers.currentAppId` — in-memory app_id, replaces `OneSignalConfigManager.getAppId/setAppId`. Sits next to the existing `storedAppId` (persisted) and `subscriptionId` (persisted) accessors. - `OneSignalConfig.shouldAwaitAppIdAndLogMissingPrivacyConsent` — same semantics, now reads `OneSignalIdentifiers.currentAppId` internally. Migrate ~30 call sites across OneSignalCore (umbrella), OneSignalOSCore, OneSignalUser, OneSignalLiveActivities, OneSignalNotifications, OneSignal- Location, OneSignalInAppMessages, OneSignalOutcomes, and the main OneSignal target. Link OneSignalOSCore.framework into OneSignalInAppMessages, One- SignalLocation, and OneSignalOutcomes targets (they didn't previously).
Those subspecs / SPM wrappers ship binaries that now link OneSignalOSCore.framework. Without the declaration, NSE-only integrations via CocoaPods or SPM wouldn't embed it and dyld would fail to load the NSE binary on the first push.
fefada6 to
898cde1
Compare
Contributor
Author
|
@claude review |
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
Consolidate vital OneSignal SDK identifier accessors (
app_id,subscription_id) into a single source so future fallback logic (cross-process / locked-state) can be added in one place.Details
Motivation
The SDK currently reads
OSUD_APP_IDandOSUD_PUSH_SUBSCRIPTION_IDfromOneSignalUserDefaultsat ~20 ad-hoc call sites across 8 modules, with three different in-memory caches (OneSignalConfigManager._appId,OSNotificationsManager._pushSubscriptionId,_user.pushSubscriptionModel.subscriptionId). This makes it difficult to add a coordinated fallback (e.g. for the iOS prewarm bug whereUserDefaultsis unreadable before first unlock). Consolidating the accessors intoOneSignalIdentifiers(durable reads) andOneSignalConfig(readiness predicate) sets up a single place for that follow-up.Scope
Three commits:
21ed8132— AddOneSignalIdentifiers.storedAppId/subscriptionIdinOneSignalOSCore. Migrate 6 durable-read sites. LinkOneSignalOSCoreintoOneSignalNotificationsandOneSignalExtensiontargets. Drop now-deadOSUD_APP_IDwrite toinitStandard.07891381— Drop redundantOSNotificationsManager._pushSubscriptionIdstatic cache + setter; the model'sdidSetalready persists. Removes drift risk and one call inOSUserExecutor.eb1a4213— ReplaceOneSignalConfigManagerwithOneSignalConfig+OneSignalIdentifiers.currentAppId(thread-safe viaNSLock). Migrate ~30 call sites across 8 modules. LinkOneSignalOSCoreintoOneSignalInAppMessages,OneSignalLocation,OneSignalOutcomes.Behavior change to note:
OneSignal.m'sprevAppIdreads previously hitinitStandard, now hitinitSharedvia the accessor. Behavior-preserving for any install on SDK 2.13.0+ (Dec 2019, commit7240697d) —handleAppIdChangehas dual-writtenOSUD_APP_IDto both stores ever since.Not changed: any externally-observable behavior. No public API changes.
Testing
Unit testing
Existing tests updated for the renamed
OneSignalConfigManager.setAppId(...)→OneSignalIdentifiers.currentAppId = ....Manual testing
Built and ran the dev app on a physical device with the SDK from source. Verified
OneSignal.User.onesignalIdandOneSignal.User.pushSubscription.idreturn the expected real values. Confirmed via temporary debug logs thatOneSignalIdentifiers.storedAppId/subscriptionIdreturn the persisted values at runtime.Affected code checklist
OneSignalIdentifiers)Checklist
Overview
Testing
Final pass