Skip to content

Commit

Permalink
feat(ios): add WebviewExtIOS (#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Jan 31, 2023
1 parent 4c6fd17 commit f546c44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/ios-webview-ext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": minor
---

Added `WebviewExtIOS` trait to access the WKWebView and userContentController references.
20 changes: 20 additions & 0 deletions src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f546c44

Please sign in to comment.