topBanner
bannerExample1[ClientAdmin] bannerExample2
Deep Link
bannerCommonSubtitle
json
scheme://host?parameter1=value1¶meter2=value2…
Key | Required | Description |
---|---|---|
scheme | required | item1 |
host | required | item2 |
parameter | optional | item3 |
value | optional | item4 |
description
step1title
step1list1
step1list2
step1list3
step1list4
swift
// LauncherWebView.swift
import WebKit
import SwiftUI
struct LauncherWebView: UIViewRepresentable {
...
// Deep Link 처리할 콜백 함수
let onDeepLink: (URL) -> Void
class Coordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
...
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
// deepLinkHandler 케이스 추가
if message.name == "deepLinkHandler", let urlString = message.body as? String, let url = URL(string: urlString) {
parent.onDeepLink(url)
}
}
...
}
...
func makeUIView(context: Context) -> WKWebView {
let webView = WKWebView()
let contentController = webView.configuration.userContentController
// javascript에서 전달하는 이벤트 등록
...
contentController.add(context.coordinator, name: "deepLinkHandler")
// script 주입
let script = """
window.open = function(url) {
window.webkit.messageHandlers.deepLinkHandler.postMessage(url);
};
"""
let scriptToInject = WKUserScript(source: script, injectionTime: .atDocumentEnd, forMainFrameOnly: false)
contentController.addUserScript(scriptToInject)
webView.navigationDelegate = context.coordinator
let request = URLRequest(url: url)
webView.load(request)
return webView
}
...
static func dismantleUIView(_ uiView: WKWebView, coordinator: Self.Coordinator) {
...
uiView.configuration.userContentController.removeScriptMessageHandler(forName: "deepLinkHandler")
}
}
step2title
step2subtitle
step2description
swift
// LauncherContentView.swift
import SwiftUI
import WebKit
struct LauncherContentView: View {
...
var body: some View {
LauncherWebView(
url: URL(string: "런처 URL"),
// Deep Link 이벤트 핸들링 처리
onDeepLink: { url in
handleDeepLink(url)
}
)
.navigationBarBackButtonHidden(true)
}
...
// Deep Link 처리
private func handleDeepLink(_ url: URL) {
// Deep Link URL 내 포함된 스키마, 호스트, 파라미터 데이터로 네비게이션 이동 처리 추가
if url.scheme == "{스키마}"{
if url.host == "{호스트명}" {
if let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems,
let exampleValue = queryItems.first(where: { $0.name == "{파라미터명}" })?.value {
navigationModel.exampleValue = exampleValue
navigationModel.path.append(.{호스트명})
}
}
}
}
}
...
footerTitle
"[Client Admin] footerMessage
v1.0.6