@@ -56,7 +56,7 @@ Outcome operations:
5656- sendOutcomeWithValue(name: String, value: Float)
5757
5858Track Event:
59- - trackEvent(name: String, value: String?)
59+ - trackEvent(name: String, properties: Map< String, Any?> ?)
6060
6161Push subscription:
6262- getPushSubscriptionId(): String?
@@ -112,6 +112,9 @@ In MainApplication.kt, set up OneSignal listeners:
112112- INotificationClickListener
113113- INotificationLifecycleListener (with preventDefault() for async display testing)
114114- IUserStateObserver (log when user state changes)
115+ - After registering listeners, restore cached SDK states from SharedPreferences:
116+ - OneSignal.InAppMessages.paused = cached paused status
117+ - OneSignal.Location.isShared = cached location shared status
115118
116119In MainViewModel.kt, implement observers:
117120- IPushSubscriptionObserver - react to push subscription changes
@@ -486,7 +489,7 @@ Example layout for section header:
486489
487490---
488491
489- ## Phase 5: Data Persistence
492+ ## Phase 5: Data Persistence & Initialization
490493
491494### What IS Persisted (SharedPreferences)
492495
@@ -499,6 +502,29 @@ SharedPreferenceUtil.kt stores:
499502- In-app messaging paused status
500503```
501504
505+ ### Initialization Flow
506+
507+ ```
508+ On app startup, state is restored in two layers:
509+
510+ 1. MainApplication.kt restores SDK state from SharedPreferences cache:
511+ - OneSignal.InAppMessages.paused = SharedPreferenceUtil.getCachedInAppMessagingPausedStatus(context)
512+ - OneSignal.Location.isShared = SharedPreferenceUtil.getCachedLocationSharedStatus(context)
513+ This ensures the SDK has the correct state before any UI is created.
514+
515+ 2. MainViewModel.loadInitialState() reads UI state from the SDK (not SharedPreferences):
516+ - _privacyConsentGiven from repository.getPrivacyConsent() (reads OneSignal.consentGiven)
517+ - _inAppMessagesPaused from repository.isInAppMessagesPaused() (reads OneSignal.InAppMessages.paused)
518+ - _locationShared from repository.isLocationShared() (reads OneSignal.Location.isShared)
519+ - _externalUserId from OneSignal.User.externalId (empty string means no user logged in)
520+ - _appId from SharedPreferenceUtil (app-level config, no SDK getter)
521+
522+ This two-layer approach ensures:
523+ - The SDK is configured with the user's last preferences before anything else runs
524+ - The ViewModel reads the SDK's actual state as the source of truth for the UI
525+ - The UI always reflects what the SDK reports, not stale cache values
526+ ```
527+
502528### What is NOT Persisted (In-Memory Only)
503529
504530```
0 commit comments