Skip to content

Instantly share code, notes, and snippets.

View nerzh's full-sized avatar
💾
cmd+s

OleH. nerzh

💾
cmd+s
View GitHub Profile
@nerzh
nerzh / WKWebViewEventListener.swift
Created November 17, 2023 15:56 — forked from iosappdeveloper/WKWebViewEventListener.swift
Add event listener from iOS code and then get callback in native code
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
print("\(#function): \(message)")
}
func setupSubViews() {
let configurations = WKWebViewConfiguration()
let controller = WKUserContentController()
let myEventScriptString =
"""
var elements = document.getElementsByClassName('button');