diff --git a/.changes/ios-webview-ext.md b/.changes/ios-webview-ext.md new file mode 100644 index 000000000..689b36e9a --- /dev/null +++ b/.changes/ios-webview-ext.md @@ -0,0 +1,5 @@ +--- +"wry": minor +--- + +Added `WebviewExtIOS` trait to access the WKWebView and userContentController references. diff --git a/src/webview/mod.rs b/src/webview/mod.rs index b3bdb1ee9..e4d529390 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -947,6 +947,26 @@ impl WebviewExtMacOS for WebView { } } +/// Additional methods on `WebView` that are specific to iOS. +#[cfg(target_os = "ios")] +pub trait WebviewExtIOS { + /// Returns WKWebView handle + fn webview(&self) -> cocoa::base::id; + /// Returns WKWebView manager [(userContentController)](https://developer.apple.com/documentation/webkit/wkscriptmessagehandler/1396222-usercontentcontroller) handle + fn manager(&self) -> cocoa::base::id; +} + +#[cfg(target_os = "ios")] +impl WebviewExtIOS for WebView { + fn webview(&self) -> cocoa::base::id { + self.webview.webview + } + + fn manager(&self) -> cocoa::base::id { + self.webview.manager + } +} + #[cfg(target_os = "android")] /// Additional methods on `WebView` that are specific to Android pub trait WebviewExtAndroid {