question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] [iOS] Toast: AlertView not finding the KeyWindow

See original GitHub issue

Is 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
J-Swiftcommented, Sep 28, 2022

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.

0reactions
VladislavAntonyukcommented, Oct 1, 2022

yes, the fix PR: https://github.com/CommunityToolkit/Maui/pull/502/files Closing it. feel free to reopen if you find the issue again

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found