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
1 changed files with 12 additions and 2 deletions

View File

@ -96,7 +96,12 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
let messagesUrl = bundleUrl.appendingPathComponent("app/_locales/\(language)/messages.json") let messagesUrl = bundleUrl.appendingPathComponent("app/_locales/\(language)/messages.json")
do { do {
let json = try String(contentsOf: messagesUrl, encoding: .utf8) 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 { } catch {
NSLog("ERROR on getLocaleStrings, \(error)") NSLog("ERROR on getLocaleStrings, \(error)")
} }
@ -236,7 +241,12 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
return return
} }
let json = (jsonSerialize(obj: message) ?? "null") 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);
})
} }
} }