Implement ios prototype version

This commit is contained in:
Donovan Preston 2018-07-27 09:20:08 -04:00
parent a80d007e0c
commit e3601055fc
No known key found for this signature in database
GPG key ID: B43EF44E428C806E
24 changed files with 1368 additions and 1 deletions

View file

@ -0,0 +1,40 @@
//
// ViewController.swift
// send-ios
//
// Created by Donovan Preston on 7/19/18.
// Copyright © 2018 Donovan Preston. All rights reserved.
//
import UIKit
import WebKit
class ViewController: UIViewController, WKScriptMessageHandler {
@IBOutlet var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
self.webView.frame = self.view.bounds
self.webView?.configuration.userContentController.add(self, name: "loaded")
self.webView?.configuration.userContentController.add(self, name: "copy")
if let url = Bundle.main.url(
forResource: "index",
withExtension: "html",
subdirectory: "assets") {
webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
}
}
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
print("Message received: \(message.name) with body: \(message.body)")
UIPasteboard.general.string = "\(message.body)"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}