fix: [SDK-4741] remove React Native activity lifecycle tracker#1951
fix: [SDK-4741] remove React Native activity lifecycle tracker#1951fadi-george wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Straightforward removal of a workaround now that the core Android SDK handles lifecycle tracking — but since this touches the init path and depends on the OneSignal 5.9.2 SDK actually observing lifecycle from process start (and device testing wasn't run), a human should confirm before merging.
Extended reasoning...
Overview
This PR removes the React Native activity lifecycle tracker workaround: deletes ActivityLifecycleTracker.java and OneSignalInitializer.java, drops the androidx.startup:startup-runtime dependency, empties the AndroidManifest of its InitializationProvider entry, and simplifies RNOneSignal.initialize to fall back through getCurrentActivity() → getApplicationContext(). The change is mechanical and self-contained.
Security risks
None identified. No auth, crypto, network, or input-handling surface is touched. The dependency removal reduces transitive surface area rather than adding to it.
Level of scrutiny
Moderate. The diff is small and mostly deletions, but it does sit on the OneSignal initialization path (OneSignal.initWithContext) which gates notification permission prompts and the rest of the SDK lifecycle. The premise — that core Android SDK 5.9.2 now observes lifecycle from process start (SDK-4732) — is not verifiable from this repo alone; if that assumption is wrong, this reintroduces the cold-start race the workaround originally solved (ApplicationService.current == null, queued permission prompts).
Other factors
The bug hunting system found no issues. The author notes device/manual notification and permission-prompt flow testing was not run, which is exactly the path most sensitive to this change. Compile-only verification (./gradlew :react-native-onesignal:compileReleaseJavaWithJavac) doesn't exercise the cold-start behavior. A human reviewer familiar with the core Android SDK changes in SDK-4732 should confirm the assumption holds in 5.9.2 before merging.
Description
One Line Summary
Removes the React Native Android activity lifecycle tracker workaround now that the core Android SDK tracks lifecycle from process start.
Details
Motivation
SDK-4732 moved activity lifecycle observation into the core Android SDK, so React Native no longer needs its own AndroidX Startup initializer to capture an Activity before bridge initialization.
Scope
This removes
ActivityLifecycleTracker,OneSignalInitializer, the AndroidX Startup manifest metadata/dependency, and simplifies initialization to use React Native's current Activity with application context fallback. It does not change the public JS API.Testing
Unit testing
bun run testManual testing
vp check srcpassed as part ofbun run lintbun run build./gradlew :react-native-onesignal:compileReleaseJavaWithJavac --rerun-tasksfromexamples/demo/androidbun run lintdid not complete because Spotless follows a generated iOS build symlink underexamples/demo/ios/buildbefore reaching this change.Affected code checklist
Checklist
Overview
Testing
Final pass
Made with Cursor