SwiftUI 14.0+ and Zoom SDK - AppDelegate issue

While Zoom SDK officially doesn’t support SwiftUI the way to use it is an example from SwiftUI and Zoom SDK

But the is a big problem with a UIWindow available from AppDelegate. It should be manually attached to window property.

let scene = UIApplication.shared.connectedScenes.first
let windowSceneDelegate = scene?.delegate as? UIWindowSceneDelegate
let window = (windowSceneDelegate?.window)!
UIApplication.shared.delegate = MyAppDelegate.Shared
let delegate = UIApplication.shared.delegate as! MyAppDelegate
delegate.window = window

But from ios14.0 SwiftUI requires to set AppDelegate by UIApplicationDelegateAdaptor

@UIApplicationDelegateAdaptor(MyAppDelegate.self) var myAppDelegate

In fact, the real AppDelegate will be SwiftUI.AppDelegate and propagating all actions to MyAppDelegate.

It is possible to set also window manually to myAppDelegate instance, and the correct window object is available by calling UIApplication.shared.delegate.window

But unfortunately, Zoom SDK is initialized and authorized but does not open/present the meeting screen. view.

Should anything else be prepared in AppDelegate to make it work?

class MyAppDelegate: NSObject, ObservableObject, UIApplicationDelegate {

static let Shared = ZoomAppDelegate()
var window: UIWindow?

}
struct StartZoomVC: UIViewControllerRepresentable {

@EnvironmentObject private var appDelegate: MyAppDelegate

[......]

func getMainWindowToShareWithAppDelegate() {
        DispatchQueue.main.async {
            let scene = UIApplication.shared.connectedScenes.first
            let windowSceneDelegate = scene?.delegate as? UIWindowSceneDelegate
            let window = (windowSceneDelegate?.window)!
            appDelegate.window = window //(UIApplication.shared.delegate?.window access is correct but doesn't work)
            UIApplication.shared.delegate = MyAppDlelegate.Shared()
            let delegate = UIApplication.shared.delegate as! MyAppDelegate
            delegate.window = window //(UIApplication.shared.delegate?.window access is correct and works)
        }

}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.