Skip to content

Commit

Permalink
connect to iOS 13's first active scene's window
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyevans committed Sep 7, 2019
1 parent b7ad7a6 commit a5e5aac
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion NotificationBanner/Classes/BaseNotificationBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,19 @@ open class BaseNotificationBanner: UIView {
var isSuspended: Bool = false

/// The main window of the application which banner views are placed on
private let appWindow: UIWindow = UIApplication.shared.delegate!.window!!
private let appWindow: UIWindow = {
if #available(iOS 13.0, *) {
let connectedScenes = UIApplication.shared.connectedScenes
for scene in connectedScenes {
if scene.activationState == .foregroundActive {
let windowScene = scene as? UIWindowScene
return windowScene?.windows.first! ?? UIWindow()
}
}
}

return UIApplication.shared.delegate!.window!!
}()

/// The position the notification banner should slide in from
private(set) var bannerPosition: BannerPosition!
Expand Down

0 comments on commit a5e5aac

Please sign in to comment.