Capacitor iOS API
Capacitor iOS is the native runtime that powers Capacitor apps on iOS.
Bridge
The iOS bridge is the heart of the Capacitor iOS library. There are several properties and methods available on the bridge which provide information or change behavior.
When registered with Capacitor, plugins have a weak reference to the bridge:
self.bridge?
If your method requires the bridge, you can use a guard to unwrap it and perform an early exit:
guard let bridge = self.bridge else { return }
viewController
var viewController: UIViewController? { get }
This property contains the main view controller for Capacitor, which can be used to present native views over the app.
Examples:
DispatchQueue.main.async {
self.bridge?.viewController.present(ourCustomViewController, animated: true, completion: nil)
}
On iPad devices it is possible to present popovers:
self.setCenteredPopover(ourCustomViewController)
self.bridge.viewController.present(ourCustomViewController, animated: true, completion: nil)
config
var config: InstanceConfiguration { get }
This property contains the configuration object known to the Capacitor runtime.
triggerJSEvent(...)
func triggerJSEvent(eventName: String, target: String)
func triggerJSEvent(eventName: String, target: String, data: String)