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/#753: iOS: Change UIScene selection logic #754

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions Rg.Plugins.Popup/Platforms/Ios/Impl/PopupPlatformIos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,24 @@ public Task AddAsync(PopupPage page)
PopupWindow window;
if (IsiOS13OrNewer)
{
if (UIApplication.SharedApplication.ConnectedScenes.ToArray()
.FirstOrDefault(x => x.ActivationState == UISceneActivationState.ForegroundActive && x is UIWindowScene) is UIWindowScene connectedScene)
window = new PopupWindow(connectedScene);
var connectedWindowScene = UIApplication.SharedApplication
.ConnectedScenes
.ToArray()
.FirstOrDefault(scene =>
{
// The popup should only be displayed on a scene that displays interactive windows
// on the device’s built-in display or an externally connected display.
if (scene.Session?.Role != UIWindowSceneSessionRole.Application)
{
return false;
}

return scene.ActivationState == UISceneActivationState.ForegroundActive
&& scene is UIWindowScene;
}) as UIWindowScene;

if (connectedWindowScene != null)
window = new PopupWindow(connectedWindowScene);
else
window = new PopupWindow();

Expand Down