https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
b

brabo-hi

10/03/2023, 2:18 AM
Hello guys, i would like to create a WebView screen the KMM ios module, i notice the ios platform UIKIt implementation on KMM doesn't provide
WKNavigationDelegate
but
WKNavigationDelegateProtocol
v

Vlad

10/03/2023, 8:53 AM
Copy code
import platform.WebKit.WKNavigationDelegateProtocol
This one works for me just fine
Oh, I missed "but" in your question. Mb
p

Pete Hellyer

10/03/2023, 10:09 AM
I wrapped the delegate inside a factory class in swift exposed by @objc and used that instead,
v

Vlad

10/03/2023, 10:10 AM
So you basically with such swift wrappers can create "kotlin-friendly" APIs and obviously have access to any apple APIs?
p

Pete Hellyer

10/03/2023, 10:12 AM
yes - especially so for 3rd party APIs in pure swift.
that advice notwithstanding @brabo-hi, I’m pretty sure you can build a class that inherits WKNavigationDelegateProtocol and set the delegate to an instance of that.
Copy code
class NavigationHander (private val callBack: (String) -> Unit): WKNavigationDelegateProtocol, NSObject()
b

brabo-hi

10/03/2023, 3:23 PM
I think creating a wrapper class is a good way to go. Thanks for your support
22 Views