Daltron / NotificationBanner

The easiest way to display highly customizable in app notification banners in iOS
MIT License
4.78k stars 662 forks source link

Fatal error with: bannerPositionFrame.startFrame #286

Closed EdwinJr13 closed 4 years ago

EdwinJr13 commented 4 years ago

When I try to display the notification on a real device it shows that error:

Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

On this line:

self.frame = bannerPositionFrame.startFrame

Help please.

shikhilnuwal commented 4 years ago

Do we have any update on the fix?

krparakhiya commented 4 years ago

Any update? because i face same error.

AlaaElrhmanArafa commented 4 years ago

same issue

gavrilaf commented 4 years ago

Have the same issue. I use the Banner from SwiftUI so I don't pass the UIViewController, banner shows on the main window.

gavrilaf commented 4 years ago

I found my case reason. The application tries to show banner when a user cancels Google/Fb authentification, so the current scene has foreground inactive state and NotificationBanner couldn't retrieve the window.

It happens here:

if #available(iOS 13.0, *) {
            return UIApplication.shared.connectedScenes
                .first { $0.activationState == .foregroundActive }
                .map { $0 as? UIWindowScene }
                .map { $0?.windows.first } ?? UIApplication.shared.delegate?.window ?? nil
        }

Dirty workaround - show notification with delay. Or add support for pending notifications and show notifications depends on application state. But it isn't the question for the library.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed due to inactivity.

sandeep9607 commented 4 years ago

please check this from author https://github.com/Daltron/NotificationBanner/pull/295#issuecomment-623175359

AlexeyLazukinIOS commented 4 years ago

had the same malfunction, ios 13.4.1, a very common scenario