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
Using string interpolation instead of Format Fixed some URLs, extracted scheme as constant
Eric Bariaux447c746e7344
diff --git a/console/iOS/NotificationExtension/NotificationService.swift b/console/iOS/NotificationExtension/NotificationService.swiftindex 9ec0675cd..83c443fe3 100644--- a/console/iOS/NotificationExtension/NotificationService.swift+++ b/console/iOS/NotificationExtension/NotificationService.swift@@ -23,7 +23,7 @@ class NotificationService: UNNotificationServiceExtension, URLSessionDelegate {defaults?.synchronize()- guard let tkurlRequest = URL(string:String(format: "https://%@/auth/realms/%@/protocol/openid-connect/token",Server.hostURL,Server.realm))+ guard let tkurlRequest = URL(string:String(format: "\(Server.scheme)://%@/auth/realms/%@/protocol/openid-connect/token",Server.hostURL,Server.realm))else { return }let tkRequest = NSMutableURLRequest(url: tkurlRequest)tkRequest.addValue("application/x-www-form-urlencoded", forHTTPHeaderField:"Content-Type");diff --git a/console/iOS/console/AppDelegate.swift b/console/iOS/console/AppDelegate.swiftindex bdc9cd12a..479959754 100644--- a/console/iOS/console/AppDelegate.swift+++ b/console/iOS/console/AppDelegate.swift@@ -115,7 +115,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDcase 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: "https://%@/%@%@", Server.hostURL, Server.navigationPath,urlToOpen as! String))!)+ (self.window?.rootViewController as! ViewController).loadUrl(url: URL(string: String(format: "\(Server.scheme)://%@/%@%@", Server.hostURL, Server.navigationPath,urlToOpen as! String))!)NSLog("Action asked : %@",response.actionIdentifier)}case ActionType.ACTION_ACTUATOR :diff --git a/console/iOS/console/Constants.swift b/console/iOS/console/Constants.swiftindex 26bc355de..f143eaa1c 100644--- a/console/iOS/console/Constants.swift+++ b/console/iOS/console/Constants.swift@@ -15,15 +15,17 @@ enum AccesTokenResult<String>}enum Server {- static let hostURL = "192.168.0.177"- static let initialPath = String(format:"console/%@/",Server.realm)- static let navigationPath = String(format:"console/%@/#/",Server.realm)+ static let scheme = "https"+ // static let hostURL = "192.168.1.145:8080"+ static let hostURL = "blok61.openremote.io"+ static let initialPath = "console/\(Server.realm)/"+ static let navigationPath = "console/\(Server.realm)/"static let realm = "blok61"- static let apiTestResource = String(format:"https://%@/%@/notification/alert",Server.hostURL,Server.realm)-// static let apiTestResource = String(format:"https://%@/%@/asset/user/current",Server.hostURL,Server.realm)+ static let apiTestResource = String(format:"\(Server.scheme)://%@/%@/notification/alert",Server.hostURL,Server.realm)+// static let apiTestResource = String(format:"\(Server.scheme)://%@/%@/asset/user/current",Server.hostURL,Server.realm)- static let registerDeviceResource = String(format:"https://%@/%@/notification/token",Server.hostURL,Server.realm)- static let deleteNotifiedAlertResource = String(format:"https://%@/%@/notification/alert/",Server.hostURL,Server.realm)+ static let registerDeviceResource = String(format:"\(Server.scheme)://%@/%@/notification/token",Server.hostURL,Server.realm)+ static let deleteNotifiedAlertResource = String(format:"\(Server.scheme)://%@/%@/notification/alert/",Server.hostURL,Server.realm)}enum Client {diff --git a/console/iOS/console/ORViewController.swift b/console/iOS/console/ORViewController.swiftindex fba9b75d6..07eba3c18 100644--- a/console/iOS/console/ORViewController.swift+++ b/console/iOS/console/ORViewController.swift@@ -113,7 +113,7 @@ class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMessageHa}*/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))}@@ -197,7 +197,7 @@ class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMessageHaUIApplication.shared.isNetworkActivityIndicatorVisible = falseErrorManager.showError(error: error!)case .Success(let accessToken) :- guard let urlRequest = URL(string: String(String(format: "https://%@/%@/asset/%@/attribute/%@", Server.hostURL, Server.realm, assetId,attributeName))) else { return }+ guard let urlRequest = URL(string: String(String(format: "\(Server.scheme)://%@/%@/asset/%@/attribute/%@", Server.hostURL, Server.realm, assetId,attributeName))) else { return }//print(urlRequest)let request = NSMutableURLRequest(url: urlRequest)request.httpMethod = "PUT"diff --git a/console/iOS/console/TokenManager.swift b/console/iOS/console/TokenManager.swiftindex c3dba5c80..29a963e4e 100644--- a/console/iOS/console/TokenManager.swift+++ b/console/iOS/console/TokenManager.swift@@ -93,7 +93,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationDmyWebView.navigationDelegate = self;viewController.view.addSubview(myWebView)UIApplication.shared.keyWindow?.rootViewController?.present(viewController, animated: true, completion: nil)- 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 }myWebView.load(URLRequest(url: request))}@@ -256,7 +256,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationD}func getAccessToken(callback: @escaping (AccesTokenResult<String>) -> ()) {- guard let tkurlRequest = URL(string: String(format:"https://%@/auth/realms/%@/protocol/openid-connect/token",Server.hostURL,Server.realm)) else { return }+ guard let tkurlRequest = URL(string: String(format:"\(Server.scheme)://%@/auth/realms/%@/protocol/openid-connect/token",Server.hostURL,Server.realm)) else { return }let tkRequest = NSMutableURLRequest(url: tkurlRequest)tkRequest.addValue("application/x-www-form-urlencoded", forHTTPHeaderField:"Content-Type");tkRequest.httpMethod = "POST"