Skip to content

Commit 2edd56e

Browse files
authored
Alert presenting vc master (#920)
* android * Scene support for alerts (#917) * scene support for alerts * move alert changes
1 parent 2e9dd12 commit 2edd56e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

React/CoreModules/RCTAlertController.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ - (UIWindow *)alertWindow
3333
- (void)show:(BOOL)animated completion:(void (^)(void))completion
3434
{
3535
[self.alertWindow makeKeyAndVisible];
36-
[self.alertWindow.rootViewController presentViewController:self animated:animated completion:completion];
36+
37+
// [TODO(macOS GH#774)
38+
// If the window is tracked by our application then it will show the alert
39+
if ([[[UIApplication sharedApplication] windows] containsObject:self.alertWindow]) {
40+
[self.alertWindow.rootViewController presentViewController:self animated:animated completion:completion];
41+
} else {
42+
// When using Scenes, we must present the alert from a view controller associated with a window in the Scene. A fresh window (i.e. _alertWindow) cannot show the alert.
43+
[RCTPresentedViewController() presentViewController:self animated:animated completion:completion];
44+
}
45+
// TODO(macOS GH#774)]
3746
}
3847
#endif // ]TODO(macOS GH#774)
3948

0 commit comments

Comments
 (0)