Skip to content

Conversation

theAmit10
Copy link

@theAmit10 theAmit10 commented Aug 21, 2025

Problem

This PR fixes a crash that occurs on iOS with newer React Native versions due to the use of deprecated AppState.removeEventListener.

Changes

  • ✅ Store AppState subscription in component instance
  • ✅ Use subscription.remove() instead of deprecated removeEventListener
  • ✅ Maintains backward compatibility
  • ✅ Fixes iOS crashes while preserving Android functionality

Code Changes

  • Added this.appStateSubscription = null in constructor
  • Changed AppState.addEventListener to store returned subscription
  • Updated cleanup to use subscription.remove()

Testing

  • ✅ Tested on iOS - no more crashes
  • ✅ Tested on Android - works as before
  • ✅ Backward compatible with older RN versions

Breaking Changes

None - this is a bug fix that maintains the same API.

Fixes #[133]

@theAmit10 theAmit10 closed this Aug 21, 2025
@theAmit10 theAmit10 reopened this Aug 21, 2025
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