Skip to content

Commit fc9647f

Browse files
fix(ios): remove tmpWindow usages on presentVC/dismissVC (#8338)
Co-authored-by: Mark Anderson <mark.anderson@outsystems.com>
1 parent ee304e3 commit fc9647f

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

ios/Capacitor/Capacitor/CAPBridgeProtocol.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ import WebKit
8181

8282
// MARK: - View Presentation
8383
func showAlertWith(title: String, message: String, buttonTitle: String)
84+
@available(*, deprecated, message: "Use self?.bridge?.viewController?.present")
8485
func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?)
86+
@available(*, deprecated, message: "Use self?.bridge?.viewController?.dismiss")
8587
func dismissVC(animated flag: Bool, completion: (() -> Void)?)
8688
}
8789

ios/Capacitor/Capacitor/CapacitorBridge.swift

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
9393
}
9494
}
9595
}
96-
96+
@available(*, deprecated, message: "obsolete")
9797
var tmpWindow: UIWindow?
98+
@available(*, deprecated, message: "obsolete")
9899
static let tmpVCAppeared = Notification(name: Notification.Name(rawValue: "tmpViewControllerAppeared"))
99100
public static let capacitorSite = "https://capacitorjs.com/"
100101
public static let fileStartIdentifier = "/_capacitor_file_"
@@ -747,22 +748,10 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
747748
}
748749

749750
@objc open func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
750-
if viewControllerToPresent.modalPresentationStyle == .popover {
751-
self.viewController?.present(viewControllerToPresent, animated: flag, completion: completion)
752-
} else {
753-
self.tmpWindow = UIWindow.init(frame: UIScreen.main.bounds)
754-
self.tmpWindow?.rootViewController = TmpViewController.init()
755-
self.tmpWindow?.makeKeyAndVisible()
756-
self.tmpWindow?.rootViewController?.present(viewControllerToPresent, animated: flag, completion: completion)
757-
}
751+
self.viewController?.present(viewControllerToPresent, animated: flag, completion: completion)
758752
}
759753

760754
@objc open func dismissVC(animated flag: Bool, completion: (() -> Void)? = nil) {
761-
if self.tmpWindow == nil {
762-
self.viewController?.dismiss(animated: flag, completion: completion)
763-
} else {
764-
self.tmpWindow?.rootViewController?.dismiss(animated: flag, completion: completion)
765-
self.tmpWindow = nil
766-
}
755+
self.viewController?.dismiss(animated: flag, completion: completion)
767756
}
768757
}

0 commit comments

Comments
 (0)