100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
iOS console : interface for native app / html app communications
William Balcaen5aab4450151d
diff --git a/console/iOS/console/ORViewController.swift b/console/iOS/console/ORViewController.swiftindex ae1d8ae5b..e6c2607b8 100644--- a/console/iOS/console/ORViewController.swift+++ b/console/iOS/console/ORViewController.swift@@ -71,7 +71,6 @@ class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMessageHa}func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void) {- let defaults = UserDefaults(suiteName: AppGroup.entitlement)var exec_template : String? = nilswitch (prompt){case "token":@@ -165,7 +164,7 @@ class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMessageHauserController.add(self, name: "int")- var exec_template : String? = ""+ let exec_template : String? = ""let userScript:WKUserScript = WKUserScript(source: exec_template!, injectionTime: .atDocumentStart, forMainFrameOnly: true)userController.addUserScript(userScript)diff --git a/console/iOS/console/TokenManager.swift b/console/iOS/console/TokenManager.swiftindex 6abc20d0b..f8b123019 100644--- a/console/iOS/console/TokenManager.swift+++ b/console/iOS/console/TokenManager.swift@@ -63,7 +63,6 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationDfunc authenticate() {NSLog("authenticate")UIApplication.shared.isNetworkActivityIndicatorVisible = true- let defaults = UserDefaults(suiteName: AppGroup.entitlement)let webCfg:WKWebViewConfiguration = WKWebViewConfiguration()let userController:WKUserContentController = WKUserContentController()@@ -107,7 +106,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationDlet type = jsonDictionnary?["type"] as! Stringswitch (type){case "token":- let tokenJsonDictionnary = jsonDictionnary?["value"] as? [String : String]+ let tokenJsonDictionnary = jsonDictionnary?["data"] as? [String : String]if (tokenJsonDictionnary?["token"] != nil &&tokenJsonDictionnary?["refreshToken"] != nil &&tokenJsonDictionnary?["idToken"] != nil){@@ -131,33 +130,8 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationDlet exec_template = "readValue = { token: \(offlineToken ?? "null"), refreshToken: \(refreshToken ?? "null"),idToken: \(idToken ?? "null")};"myWebView.evaluateJavaScript(exec_template, completionHandler: nil)}- /* do {- let json = try JSONSerialization.jsonObject(with: (((jsonDictionnary?["value"]!) as! String).data(using: String.Encoding.utf8)!), options: .allowFragments)- let jsonDictionnary = json as? [String : String]- offlineToken = jsonDictionnary?["token"]! ?? nil- refreshToken = jsonDictionnary?["refreshToken"]! ?? nil- idToken = jsonDictionnary?["idToken"]! ?? nil- defaults?.set(offlineToken, forKey: DefaultsKey.token)- defaults?.set(refreshToken, forKey: DefaultsKey.refreshToken)- defaults?.set(idToken, forKey: DefaultsKey.idToken)- if (offlineToken != nil && refreshToken != nil && idToken != nil && !didLogOut) {- self.hasToken = true- if let vc = viewController.presentingViewController as? ViewController {- vc.isInError = false- }- UIApplication.shared.isNetworkActivityIndicatorVisible = false- self.viewController.dismiss(animated: false, completion: {- let notificationName = Notification.Name(NotificationsNames.isAuthenticated)- NotificationCenter.default.post(name: notificationName, object: nil)- })- let exec_template = "readValue = { token: \(offlineToken ?? "null"), refreshToken: \(refreshToken ?? "null"),idToken: \(idToken ?? "null")};"- myWebView.evaluateJavaScript(exec_template, completionHandler: nil)- }- } catch {- print("Error deserializing JSON: \(error)")- }*/default:- print("Unknown message type: \(type ?? "")")+ print("Unknown message type: \(type )")}}@@ -167,7 +141,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationDswitch (prompt){case "token":if offlineToken != nil && refreshToken != nil && idToken != nil && didLogOut == false {- exec_template = "readValue = { token: \(offlineToken ?? "null"), refreshToken: \(refreshToken ?? "null"),idToken: \(idToken ?? "null")};"+ exec_template = "{ \"token\": \"\(offlineToken ?? "null")\", \"refreshToken\": \"\(refreshToken ?? "null")\",\"idToken\": \"\(idToken ?? "null")\"};"}default: