Skip to content

Commit 6bfd7e1

Browse files
authored
Added condition in WindowStateManager for selecting proper scene used with role Application (#23945)
1 parent cd7107e commit 6bfd7e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Essentials/src/Platform/WindowStateManager.ios.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ public void Init(Func<UIViewController?>? getCurrentUIViewController) =>
140140
try
141141
{
142142
using var scenes = UIApplication.SharedApplication.ConnectedScenes;
143-
var windowScene = scenes.ToArray<UIWindowScene>().FirstOrDefault();
143+
var windowScene = scenes.ToArray().OfType<UIWindowScene>().FirstOrDefault(scene =>
144+
scene.Session.Role == UIWindowSceneSessionRole.Application);
144145
return windowScene?.Windows.FirstOrDefault();
145146
}
146147
catch (InvalidCastException)
@@ -163,7 +164,8 @@ public void Init(Func<UIViewController?>? getCurrentUIViewController) =>
163164
try
164165
{
165166
using var scenes = UIApplication.SharedApplication.ConnectedScenes;
166-
var windowScene = scenes.ToArray<UIWindowScene>().FirstOrDefault();
167+
var windowScene = scenes.ToArray().OfType<UIWindowScene>().FirstOrDefault(scene =>
168+
scene.Session.Role == UIWindowSceneSessionRole.Application);
167169
return windowScene?.Windows;
168170
}
169171
catch (InvalidCastException)

0 commit comments

Comments
 (0)