rotorgames / Rg.Plugins.Popup

Xamarin Forms popup plugin
MIT License
1.15k stars 337 forks source link

SceneDelegate is not working correctly on iOS #676

Closed jpiechowiak closed 2 years ago

jpiechowiak commented 3 years ago

🐛 Bug Report

I'm developing CarPlay application and I'm using concept of SceneDelegate. When there is only mobile app turned on, then everything is ok. When after some time, I'm connecting to CarPlay, then I've two scene delegates which are foreground. In such situation, CarPlay scene sometimes could be first in collection of ConnectedScenes and my popups are not displayed because.

Regarding to this code (https://github.com/rotorgames/Rg.Plugins.Popup/blob/develop/Rg.Plugins.Popup/Platforms/Ios/Impl/PopupPlatformIos.cs#L61)

var connectedScene = UIApplication.SharedApplication.ConnectedScenes.ToArray().FirstOrDefault(x => x.ActivationState == UISceneActivationState.ForegroundActive);
if (connectedScene != null && connectedScene is UIWindowScene windowScene)
    window = new PopupWindow(windowScene);
else
    window = new PopupWindow();

I think that there should be some OrderBy which will be sorting this collection according to UIWindowScene, which is needed in next step.

Here is also my declaration of CarPlaySceneDelegate:

public class CarPlaySceneDelegate : UIResponder, ICPTemplateApplicationSceneDelegate
{
 //...
}

Expected behavior

UIWindowScene has bigger priority than other Windows. Popup is always opened inside mobile application

Reproduction steps

Configuration

Default

Version: 2.0.0.12

Platform: