Skip to content

Commit

Permalink
feat(ios): Add setServerBasePath(path:) to CAPWebView (#5742) (#5748)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven0351 committed Jul 12, 2022
1 parent bb54ac1 commit 9c25aad
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ios/Capacitor/Capacitor/CAPWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ open class CAPWebView: UIView {
open func loadInitialContext(_ userContentController: WKUserContentController) {
CAPLog.print("in loadInitialContext base")
}

public func setServerBasePath(path: String) {
let url = URL(fileURLWithPath: path, isDirectory: true)
guard FileManager.default.fileExists(atPath: url.path) else { return }

capacitorBridge.config = capacitorBridge.config.updatingAppLocation(url)
capacitorBridge.webViewAssetHandler.setAssetPath(url.path)

DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
_ = self.webView.load(URLRequest(url: self.capacitorBridge.config.serverURL))
}
}
}

extension CAPWebView {
Expand Down

0 comments on commit 9c25aad

Please sign in to comment.