[BUG] [iOS] Toast: AlertView not finding the KeyWindow
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current Behavior
Crashing on iOS device
System.InvalidOperationException: KeyWindow is not found
at CommunityToolkit.Maui.Core.Views.AlertView.get_ParentView() in /_/src/CommunityToolkit.Maui.Core/Views/Alert/AlertView.macios.cs:line 17
at CommunityToolkit.Maui.Core.Views.Alert..ctor() in /_/src/CommunityToolkit.Maui.Core/Views/Alert/Alert.macios.cs:line 17
at CommunityToolkit.Maui.Core.Views.PlatformToast..ctor(String message, UIColor backgroundColor, CGRect cornerRadius, UIColor textColor, UIFont font, Double characterSpacing, NFloat padding) in /_/src/CommunityToolkit.Maui.Core/Views/Toast/PlatformToast.macios.cs:line 28
at CommunityToolkit.Maui.Alerts.Toast.ShowPlatform(CancellationToken token) in /_/src/CommunityToolkit.Maui/Alerts/Toast/Toast.macios.cs:line 53
at CommunityToolkit.Maui.Alerts.Toast.Show(CancellationToken token) in /_/src/CommunityToolkit.Maui/Alerts/Toast/Toast.shared.cs:line 77
Expected Behavior
Don’t crash.
Steps To Reproduce
using var t = Toast.Make("Something to say", CommunityToolkit.Maui.Core.ToastDuration.Long);
await t.Show();
Link to public reproduction project repository
(tbd)
Environment
- .NET MAUI CommunityToolkit: 1.3.0
- OS: iOS 15
- .NET MAUI: 6.0.536/6.0.400
Anything else?
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:18 (3 by maintainers)
Top Results From Across the Web
UIAlertViews, UIActionSheets and keyWindow problems
Adding the view to keyWindow creates the problem I described, not being added before going to background, not being shown on the multitasking ......
Read more >How to present an alert window in
The problem is - it might not be the top viewController so you have to move to its presentedViewController if it is presenting...
Read more >[Answer]-Create toast when log out (iOS)-swift
I came across the problem when a user logs out, a toast message "You logged out" should be displayed on the first view...
Read more >elai950/AlertToast: Create Apple-like alerts & toasts using ...
Create Apple-like alerts & toasts using SwiftUI. Contribute to elai950/AlertToast development by creating an account on GitHub.
Read more >Swift notification banner. 0+ macOS 11. For the change to take fu
A The easiest way to display highly customizable in app notification banners in iOS Written in Swift 5 NotificationBanner is an extremely customizable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The ASWebAuthenticationSession is 100% reproducible every time you press cancel, but I will need to get an example outside of my main app that shows this.
yes, the fix PR: https://github.com/CommunityToolkit/Maui/pull/502/files Closing it. feel free to reopen if you find the issue again