Skip to content

fix: [SDK-4741] remove React Native activity lifecycle tracker#1951

Closed
fadi-george wants to merge 1 commit into
mainfrom
fadi/sdk-4741
Closed

fix: [SDK-4741] remove React Native activity lifecycle tracker#1951
fadi-george wants to merge 1 commit into
mainfrom
fadi/sdk-4741

Conversation

@fadi-george

Copy link
Copy Markdown
Collaborator

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 test

Manual testing

  • vp check src passed as part of bun run lint
  • bun run build
  • ./gradlew :react-native-onesignal:compileReleaseJavaWithJavac --rerun-tasks from examples/demo/android
  • Full bun run lint did not complete because Spotless follows a generated iOS build symlink under examples/demo/ios/build before reaching this change.
  • Device/manual notification or permission prompt flow testing was not run.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@fadi-george fadi-george requested a review from a team as a code owner June 3, 2026 02:27

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fadi-george fadi-george closed this Jun 3, 2026
@fadi-george fadi-george deleted the fadi/sdk-4741 branch June 3, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant