1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-07 09:31:31 +01:00

set app version in query string

This commit is contained in:
Kyle Spearrin 2019-08-20 23:12:35 -04:00
parent 09947b95aa
commit 8defddfdd1

View File

@ -24,12 +24,13 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
if initedWebView { if initedWebView {
return return
} }
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
initedWebView = true initedWebView = true
let parentHeight = SafariExtensionViewController.shared.preferredContentSize.height let parentHeight = SafariExtensionViewController.shared.preferredContentSize.height
let parentWidth = SafariExtensionViewController.shared.preferredContentSize.width let parentWidth = SafariExtensionViewController.shared.preferredContentSize.width
let webViewConfig = WKWebViewConfiguration() let webViewConfig = WKWebViewConfiguration()
let bundleURL = Bundle.main.resourceURL!.absoluteURL let bundleURL = Bundle.main.resourceURL!.absoluteURL
let html = bundleURL.appendingPathComponent("app/popup/index.html") let html = bundleURL.appendingPathComponent("app/popup/index.html?appVersion=\(version!)")
webViewConfig.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs") webViewConfig.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
webViewConfig.preferences.setValue(true, forKey: "developerExtrasEnabled") webViewConfig.preferences.setValue(true, forKey: "developerExtrasEnabled")
webViewConfig.userContentController.add(self, name: "bitwardenApp") webViewConfig.userContentController.add(self, name: "bitwardenApp")
@ -69,8 +70,9 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
let command = m!.command let command = m!.command
// print(command) // print(command)
if command == "windowLoaded" { if command == "windowLoaded" {
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String // let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
webView.evaluateJavaScript("window.bitwardenApplicationVersion = '\(version)';", completionHandler: nil) // webView.evaluateJavaScript("window.bitwardenApplicationVersion = '\(version!)';", completionHandler: nil)
// Set things
} else if command == "storage_get" { } else if command == "storage_get" {
let obj = UserDefaults.standard.string(forKey: m!.data!) let obj = UserDefaults.standard.string(forKey: m!.data!)
m!.responseData = obj m!.responseData = obj