Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RCTAlertController not showing when using SceneDelegate on iOS 13.0+ #35716

Closed
wants to merge 2 commits into from

Conversation

ouabing
Copy link

@ouabing ouabing commented Dec 25, 2022

Summary

On iOS 13.0+, app may use SceneDelegate for multiple windows support or CarPlay support. RCTAlertController can't find the correct root vc in such scene based apps.

Changelog

[iOS] [Fixed] - Fix RCTAlertController not showing when using SceneDelegate on iOS 13.0+.

Test Plan

@facebook-github-bot
Copy link
Contributor

Hi @ouabing!

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 [email protected]. Thanks!

@analysis-bot
Copy link

analysis-bot commented Dec 25, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,494,185 +0
android hermes armeabi-v7a 7,814,776 +0
android hermes x86 8,970,115 +0
android hermes x86_64 8,828,201 +0
android jsc arm64-v8a 9,679,692 +0
android jsc armeabi-v7a 8,413,897 +0
android jsc x86 9,744,208 +0
android jsc x86_64 10,221,524 +0

Base commit: 9c57a7f
Branch: main

@analysis-bot
Copy link

analysis-bot commented Dec 25, 2022

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 9c57a7f
Branch: main

@pull-bot
Copy link

PR build artifact for e468621 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

PR build artifact for e468621 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 25, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link
Contributor

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

Copy link
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.

The code seems ok to me, I left a couple of questions to understand it better and see whether we can simplify it a little bit.

Also, can we extract lone 24 to 34 into a private function? Something like:

- (UIWindow *)getUIWindowFromScene
{
  // ...moved code...
}

This will make it easier to read the code and to eventually change/remove the code once we don't need all the checks.

What do you think?

React/CoreModules/RCTAlertController.m Outdated Show resolved Hide resolved
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, *)) {
for (UIScene *scene in RCTSharedApplication().connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive && [scene isKindOfClass:[UIWindowScene class]]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the check [scene isKindOfClass:[UIWindowScene class]] is needed? Can scene be of something different from a UIWindowScene class?

Copy link
Author

@ouabing ouabing Dec 31, 2022

Choose a reason for hiding this comment

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

For app supports CarPlay, RCTSharedApplication().connectedScenes will include CarPlay scenes such as CPTemplateApplicationScene instance, which may also in active state.

@pull-bot
Copy link

PR build artifact for 50273c0 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

PR build artifact for 50273c0 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

PR build artifact for cb78e7e is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

PR build artifact for cb78e7e is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@facebook-github-bot
Copy link
Contributor

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

@makovkastar
Copy link
Contributor

@ouabing can you please rebase this PR on top of the latest commit? There are some merge conflicts.

@pull-bot
Copy link

pull-bot commented Jan 4, 2023

PR build artifact for 03de6eb is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

pull-bot commented Jan 4, 2023

PR build artifact for 03de6eb is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@ouabing
Copy link
Author

ouabing commented Jan 4, 2023

@makovkastar done, thank you all

@facebook-github-bot
Copy link
Contributor

@makovkastar 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 Jan 4, 2023
@facebook-github-bot
Copy link
Contributor

@makovkastar merged this pull request in 0c53420.

kelset pushed a commit that referenced this pull request Jan 19, 2023
….0+ (#35716)

Summary:
On iOS 13.0+, app may use SceneDelegate for multiple windows support or CarPlay support. RCTAlertController can't find the correct root vc in such scene based apps.

## Changelog

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Fixed] - Fix RCTAlertController not showing when using SceneDelegate on iOS 13.0+.

Pull Request resolved: #35716

Reviewed By: cipolleschi

Differential Revision: D42253653

Pulled By: makovkastar

fbshipit-source-id: ae4e833abca2af7af8028f3af9bd8d3f60ebd392
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
….0+ (facebook#35716)

Summary:
On iOS 13.0+, app may use SceneDelegate for multiple windows support or CarPlay support. RCTAlertController can't find the correct root vc in such scene based apps.

## Changelog

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Fixed] - Fix RCTAlertController not showing when using SceneDelegate on iOS 13.0+.

Pull Request resolved: facebook#35716

Reviewed By: cipolleschi

Differential Revision: D42253653

Pulled By: makovkastar

fbshipit-source-id: ae4e833abca2af7af8028f3af9bd8d3f60ebd392
vonovak added a commit to vonovak/react-native-simple-toast that referenced this pull request Aug 1, 2023
vonovak added a commit to vonovak/react-native-simple-toast that referenced this pull request Aug 1, 2023
* fix: unbalanced calls to begin/end appearance transitions

* fix: update how toastWindow is obtained

see facebook/react-native#35716
dnamrata0805 added a commit to dnamrata0805/react-native-fork that referenced this pull request Sep 20, 2023
@cipolleschi cipolleschi mentioned this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 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. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants