1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-25 09:32:06 +01:00

Merge pull request #1349 from bitwarden/fix/safar-completion-handler-nil

Added logging and completion handler for JS
This commit is contained in:
Chad Scharf 2020-08-03 11:25:51 -04:00 committed by GitHub
commit 5861a51d54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,7 +96,12 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
let messagesUrl = bundleUrl.appendingPathComponent("app/_locales/\(language)/messages.json")
do {
let json = try String(contentsOf: messagesUrl, encoding: .utf8)
webView.evaluateJavaScript("window.bitwardenLocaleStrings = \(json);", completionHandler: nil)
webView.evaluateJavaScript("window.bitwardenLocaleStrings = \(json);", completionHandler: {(result, error) in
guard let err = error else {
return;
}
NSLog("evaluateJavaScript error : %@", err.localizedDescription);
})
} catch {
NSLog("ERROR on getLocaleStrings, \(error)")
}
@ -236,7 +241,12 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
return
}
let json = (jsonSerialize(obj: message) ?? "null")
webView.evaluateJavaScript("window.bitwardenSafariAppMessageReceiver(\(json));", completionHandler: nil)
webView.evaluateJavaScript("window.bitwardenSafariAppMessageReceiver(\(json));", completionHandler: {(result, error) in
guard let err = error else {
return;
}
NSLog("evaluateJavaScript error : %@", err.localizedDescription);
})
}
}