Skip to content

Fix applicationDidEnterBackground not being called#48376

Closed
alextoudic wants to merge 1 commit intofacebook:mainfrom
alextoudic:main
Closed

Fix applicationDidEnterBackground not being called#48376
alextoudic wants to merge 1 commit intofacebook:mainfrom
alextoudic:main

Conversation

@alextoudic
Copy link
Copy Markdown
Contributor

@alextoudic alextoudic commented Dec 23, 2024

Summary:

I noticed that AppDelegate subscribers listening for applicationDidEnterBackground events in Expo projects (as documented here aren't working as expected anymore.
While investigating, I discovered that the events aren't reaching the ExpoAppDelegate implementation (source) because the RCTAppDelegate implementation of applicationDidEnterBackground interrupts the event chain. This appears to be affecting some legitimate use cases.
I believe we could improve this by removing the current implementation, but I'd love to hear your thoughts on this approach. I might be missing some context about why this implementation was originally needed, so any insights would be greatly appreciated!

Changelog:

[IOS] [FIXED] - Fix applicationDidEnterBackground not being called

Test Plan:

Ran a local test after change

@facebook-github-bot
Copy link
Copy Markdown
Contributor

Hi @alextoudic!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Dec 23, 2024
Copy link
Copy Markdown
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 24, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@cipolleschi merged this pull request in adaceba.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @alextoudic in adaceba

When will my fix make it into a release? | How to file a pick request?

facebook-github-bot pushed a commit that referenced this pull request Dec 27, 2024
Summary:
#48376 removed `applicationDidEnterBackground` from `RCTAppDelegate` but RNTester called it, leads to crash. cc cipolleschi can you please help to review?

## Changelog:

[INTERNAL] [FIXED] - RNTester: Fixes crash when app back to background

Pull Request resolved: #48385

Test Plan: RNTester iOS back to background not crash.

Reviewed By: cipolleschi

Differential Revision: D67657449

Pulled By: philIip

fbshipit-source-id: e6d806b2677050fa2faa273a7468055d9d21c2a3
cortinico pushed a commit that referenced this pull request Feb 5, 2025
Summary:
I noticed that `AppDelegate` subscribers listening for `applicationDidEnterBackground` events in Expo projects (as documented [here](https://github.com/expo/expo/blob/238b6f57e459dd2c0b13ee158f0af709fe922460/docs/pages/modules/appdelegate-subscribers.mdx?plain=1#L56) aren't working as expected anymore.
While investigating, I discovered that the events aren't reaching the `ExpoAppDelegate` implementation ([source](https://github.com/expo/expo/blob/71f2c55ff3f11e43ab43761bb5cece2e48eae0bf/packages/expo-modules-core/ios/AppDelegates/ExpoAppDelegate.swift#L61)) because the `RCTAppDelegate` implementation of `applicationDidEnterBackground` interrupts the event chain. This appears to be affecting some legitimate use cases.
I believe we could improve this by removing the current implementation, but I'd love to hear your thoughts on this approach. I might be missing some context about why this implementation was originally needed, so any insights would be greatly appreciated!

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[IOS] [FIXED] - Fix applicationDidEnterBackground not being called

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[IOS] [FIXED] - Fix applicationDidEnterBackground not being called

Pull Request resolved: #48376

Test Plan: Ran a local test after change

Reviewed By: javache

Differential Revision: D67621557

Pulled By: cipolleschi

fbshipit-source-id: 2d73711372deba867bd616c79ef4d00c79aa86d5
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @alextoudic in ecb9c58

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants