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
Merge branch 'master' of github.com:openremote/openremote
Eric Bariaux4d1971ca9827
diff --cc console/iOS/console/AppDelegate.swiftindex 479959754,fe2e83592..11382f467--- a/console/iOS/console/AppDelegate.swift+++ b/console/iOS/console/AppDelegate.swift@@@ -113,10 -104,10 +104,10 @@@ class AppDelegate: UIResponder, UIAppliUIApplication.shared.isNetworkActivityIndicatorVisible = trueswitch response.actionIdentifier {case ActionType.ACTION_DEEP_LINK :- // open urlif let urlToOpen = response.notification.request.content.userInfo["appUrl"] { // until now we are considering anchor name (without the #)- (self.window?.rootViewController as! ViewController).loadUrl(url: URL(string: String(format: "\(Server.scheme)://%@/%@%@", Server.hostURL, Server.navigationPath,urlToOpen as! String))!)- guard let urlRequest = URL(string:String(format: "https://%@/%@%@", Server.hostURL, Server.navigationPath,urlToOpen as! String)) else { return }- (self.window?.rootViewController as! ViewController).loadUrl(url:urlRequest)-- NSLog("Action asked : %@",response.actionIdentifier)++ guard let urlRequest = URL(string:String(format: "https://%@/%@%@", Server.hostURL, Server.navigationPath,urlToOpen as! String)) else { return }++ (self.window?.rootViewController as! ViewController).loadUrl(url:urlRequest)++ NSLog("Action asked : %@",response.actionIdentifier)}case ActionType.ACTION_ACTUATOR :NSLog("Action asked : %@",response.actionIdentifier)diff --cc console/iOS/console/ORViewController.swiftindex 07eba3c18,50f9cf153..db10223a2--- a/console/iOS/console/ORViewController.swift+++ b/console/iOS/console/ORViewController.swift@@@ -70,50 -70,8 +70,8 @@@ class ORViewcontroller : UIViewControlldecisionHandler(.allow)}- /*- // just for testing purpose (ask backend to get list of notifications or send a notification to device)- func apiCall() {- UIApplication.shared.isNetworkActivityIndicatorVisible = true- TokenManager.sharedInstance.getAccessToken { (accessTokenResult) in- switch accessTokenResult {- case .Failure(let error) :- UIApplication.shared.isNetworkActivityIndicatorVisible = false- print(error ?? "")- ErrorManager.showError(error: NSError(domain: "", code: 0, userInfo: [- NSLocalizedDescriptionKey : NSLocalizedString("ErrorCallingapi", value: "Delete app and restart token probably expired", comment: "")- ]))-- case .Success(let accessToken) :- guard let urlRequest = URL(string: String(Server.apiTestResource)) else { return }- let request = NSMutableURLRequest(url: urlRequest)- request.httpMethod = "POST" // post to create a notification alert, get to get a list of notification alerts- request.addValue("application/json", forHTTPHeaderField: "Content-Type")- request.httpBody = "{\"title\" :\" notif alert title\",\"message\" : \"notif alert message\",\"appUrl\" : \"Veilig\",\"actions\": [ {\"title\" : \"Open link\" , \"type\": \"ACTION_DEEP_LINK\"},{\"title\" : \"background call\" , \"type\": \"ACTION_ACTUATOR\" , \"assetId\" : \"2E2vrICRSEa6mfzOquZzxA\", \"attributeName\" : \"targetTemp\", \"rawJson\" : \"18\" } ]}".data(using: .utf8)- request.addValue(String(format:"Bearer %@", accessToken!), forHTTPHeaderField: "Authorization")- let sessionConfiguration = URLSessionConfiguration.default- let session = URLSession(configuration: sessionConfiguration, delegate: self, delegateQueue : nil)- let reqDataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) in- DispatchQueue.main.async {- UIApplication.shared.isNetworkActivityIndicatorVisible = false- if (error != nil) {- NSLog("error %@", (error! as NSError).localizedDescription)- let error = NSError(domain: "", code: 0, userInfo: [- NSLocalizedDescriptionKey : NSLocalizedString("ErrorCallingAPI", value: "Could not get data", comment: "")- ])- ErrorManager.showError(error: error)- } else {- print(response.debugDescription)- _ = self.myWebView?.load(data!, mimeType: "text/html", characterEncodingName: "utf8", baseURL: URL(string:Server.apiTestResource)!)- }- }- })- reqDataTask.resume()- }- }- }- */func login() {- guard let request = URL(string: String(format:"https://%@/%@",Server.hostURL,Server.initialPath)) else { return }+ guard let request = URL(string: String(format:"\(Server.scheme)://%@/%@",Server.hostURL,Server.initialPath)) else { return }UIApplication.shared.isNetworkActivityIndicatorVisible = true_ = self.myWebView?.load(URLRequest(url: request))}diff --cc console/iOS/console/TokenManager.swiftindex 29a963e4e,96d23fbc8..ec4324b94--- a/console/iOS/console/TokenManager.swift+++ b/console/iOS/console/TokenManager.swift@@@ -92,8 -91,12 +91,11 @@@ class TokenManager:NSObject, WKScriptMemyWebView.uiDelegate = self;myWebView.navigationDelegate = self;viewController.view.addSubview(myWebView)- UIApplication.shared.keyWindow?.rootViewController?.present(viewController, animated: true, completion: nil)- guard let request = URL(string: String(format:"\(Server.scheme)://%@/%@",Server.hostURL,Server.initialPath)) else { return }+ if (UIApplication.shared.keyWindow?.rootViewController?.presentedViewController == nil) {+ UIApplication.shared.keyWindow?.rootViewController?.present(viewController, animated: true, completion: nil)+ }+-+ guard let request = URL(string: String(format:"https://%@/%@",Server.hostURL,Server.initialPath)) else { return }myWebView.load(URLRequest(url: request))}