handle incoming url for appclip

This commit is contained in:
Hailey
2024-06-16 19:09:26 -07:00
parent 10d4d10714
commit 07696d8eb7
3 changed files with 33 additions and 7 deletions
+17 -2
View File
@@ -1,17 +1,32 @@
import UIKit
// https://dc19-24-237-65-73.ngrok-free.app/start/haileyok.com/3kuw7byr7gd2x
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var controller: ViewController?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow()
let controller = ViewController()
self.controller = ViewController()
self.window?.rootViewController = controller
self.window?.rootViewController = self.controller
self.window?.makeKeyAndVisible()
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
self.controller?.handleURL(url: url)
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let incomingURL = userActivity.webpageURL {
self.controller?.handleURL(url: incomingURL)
}
return true
}
}
+9 -3
View File
@@ -12,9 +12,15 @@ class ViewController: UIViewController {
webView.contentMode = .scaleToFill
self.view.addSubview(webView)
if let url = URL(string: "http://localhost:19006/start/haileyok.com/3kuw7byr7gd2x?clip=true") {
webView.load(URLRequest(url: url))
self.webView = webView
}
func handleURL(url: URL) {
let urlString = "\(url.absoluteString)?clip=true"
if let url = URL(string: urlString) {
self.webView?.load(URLRequest(url: url))
}
}
}