Skip to content

Instantly share code, notes, and snippets.

View rmaafs's full-sized avatar
🏠
Working from home

Rodrigo Maafs rmaafs

🏠
Working from home
View GitHub Profile
@rmaafs
rmaafs / App.js
Last active November 17, 2023 00:12
Communication between ReactJS WebPage and Swift App (WKWebView)
import useAppMessage from "./hooks/useAppMessage";
import "./App.css";
function App() {
const { appMessage, sendAppMessage } = useAppMessage(); // appMessage is the message received from the Swift APP
const handlePlay = () => {
sendAppMessage("Hello from page!");//Send message to the Swift APP
};
@rmaafs
rmaafs / ContentView.swift
Created December 1, 2023 21:12
WebView without edges
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
let urlString: String = "http://localhost:3000"
class Coordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
var webView: WKWebView?
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {