Skip to content

Commit

Permalink
Added condition in WindowStateManager for selecting proper scene used…
Browse files Browse the repository at this point in the history
… with role Application (#23945)
  • Loading branch information
jpiechowiak authored Aug 6, 2024
1 parent cd7107e commit 6bfd7e1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Essentials/src/Platform/WindowStateManager.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public void Init(Func<UIViewController?>? getCurrentUIViewController) =>
try
{
using var scenes = UIApplication.SharedApplication.ConnectedScenes;
var windowScene = scenes.ToArray<UIWindowScene>().FirstOrDefault();
var windowScene = scenes.ToArray().OfType<UIWindowScene>().FirstOrDefault(scene =>
scene.Session.Role == UIWindowSceneSessionRole.Application);
return windowScene?.Windows.FirstOrDefault();
}
catch (InvalidCastException)
Expand All @@ -163,7 +164,8 @@ public void Init(Func<UIViewController?>? getCurrentUIViewController) =>
try
{
using var scenes = UIApplication.SharedApplication.ConnectedScenes;
var windowScene = scenes.ToArray<UIWindowScene>().FirstOrDefault();
var windowScene = scenes.ToArray().OfType<UIWindowScene>().FirstOrDefault(scene =>
scene.Session.Role == UIWindowSceneSessionRole.Application);
return windowScene?.Windows;
}
catch (InvalidCastException)
Expand Down

0 comments on commit 6bfd7e1

Please sign in to comment.