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
Updated cocoapod
Michael Rademakeraec051be567d
diff --git a/console/iOS/ORLib/ORLib.podspec b/console/iOS/ORLib/ORLib.podspecindex 8408d996f..3ce4d54bc 100644--- a/console/iOS/ORLib/ORLib.podspec+++ b/console/iOS/ORLib/ORLib.podspec@@ -11,7 +11,7 @@ Pod::Spec.new do |s|s.requires_arc = trues.version = '1.1.0's.authors = 'OpenRemote'- s.homepage = "http://www.openremote.com/community/"+ s.homepage = "http://www.openremote.io"s.source = { :git => 'https://github.com/openremote/openremote.git', :tag => 'cocoapod' + s.version.to_s }s.dependency 'Firebase/Core', '4.6.0's.dependency 'Firebase/Messaging', '4.6.0'diff --git a/console/iOS/ORLib/ORLib.xcodeproj/project.xcworkspace/xcuserdata/michael.xcuserdatad/UserInterfaceState.xcuserstate b/console/iOS/ORLib/ORLib.xcodeproj/project.xcworkspace/xcuserdata/michael.xcuserdatad/UserInterfaceState.xcuserstateindex c22901c3a..4e8bb4599 100644Binary files a/console/iOS/ORLib/ORLib.xcodeproj/project.xcworkspace/xcuserdata/michael.xcuserdatad/UserInterfaceState.xcuserstate and b/console/iOS/ORLib/ORLib.xcodeproj/project.xcworkspace/xcuserdata/michael.xcuserdatad/UserInterfaceState.xcuserstate differdiff --git a/console/iOS/ORLib/ORLib/ConsoleProviders/GeofenceProvider.swift b/console/iOS/ORLib/ORLib/ConsoleProviders/GeofenceProvider.swiftdeleted file mode 100644index da521ff46..000000000--- a/console/iOS/ORLib/ORLib/ConsoleProviders/GeofenceProvider.swift+++ /dev/null@@ -1,215 +0,0 @@-import UIKit-import CoreLocation--public class GeofenceProvider: NSObject, URLSessionDelegate {-- static let baseUrlKey = "baseUrl"- static let consoleIdKey = "consoleId"- static let geoPostUrlsKey = "geoPostUrls"-- let version = "ORConsole"- let geofenceFetchEndpoint = "rules/geofences/"- let locationManager = CLLocationManager()- let userdefaults = UserDefaults.standard- var geoPostUrls = [String:String]()- var initializeCallback : (([String: Any]) -> (Void))?-- public var baseURL: String = ""- public var consoleId: String = ""-- public override init() {- super.init()- locationManager.delegate = self- self.baseURL = userdefaults.string(forKey: GeofenceProvider.baseUrlKey) ?? ""- self.consoleId = userdefaults.string(forKey: GeofenceProvider.consoleIdKey) ?? ""- self.geoPostUrls = userdefaults.value(forKey: GeofenceProvider.geoPostUrlsKey) as? [String:String] ?? [String:String]()- }-- public func initialize(callback:@escaping ([String: Any]) ->(Void)) {- initializeCallback = callback- if checkPermission() {- initializeCallback?([- DefaultsKey.actionKey: Actions.providerInit,- DefaultsKey.providerKey: Providers.geofence,- DefaultsKey.versionKey: version,- DefaultsKey.requiresPermissionKey: true,- DefaultsKey.hasPermissionKey: checkPermission(),- DefaultsKey.successKey: true- ])- } else {- registerPermissions()- }- }-- private func checkPermission() -> Bool {- if CLLocationManager.locationServicesEnabled() {- if CLLocationManager.authorizationStatus() == .authorizedAlways{- return true- }- }- return false- }-- private func registerPermissions() {- locationManager.requestAlwaysAuthorization()- }-- public func addGeofence(geofence: GeofenceDefinition) {- let region = CLCircularRegion(center: CLLocationCoordinate2DMake(geofence.lat, geofence.lng), radius: geofence.radius, identifier:geofence.id)- locationManager.startMonitoring(for: region)- geoPostUrls[geofence.id] = geofence.postUrl- userdefaults.set(geoPostUrls, forKey: GeofenceProvider.geoPostUrlsKey)- userdefaults.synchronize()- }-- public func removeGeofence(id: String) {- for region in locationManager.monitoredRegions {- guard let circularRegion = region as? CLCircularRegion, circularRegion.identifier == id else {continue}- locationManager.stopMonitoring(for: circularRegion)- geoPostUrls.removeValue(forKey: circularRegion.identifier)- userdefaults.set(geoPostUrls, forKey: GeofenceProvider.geoPostUrlsKey)- userdefaults.synchronize()- break- }- }-- public func clearAllRegions() {- for region in locationManager.monitoredRegions {- locationManager.stopMonitoring(for: region)- }- geoPostUrls = [String:String]()- userdefaults.set(geoPostUrls, forKey: GeofenceProvider.geoPostUrlsKey)- userdefaults.synchronize()- }-- public func enable(baseUrl: String, consoleId: String)-> [String: Any] {- self.baseURL = baseUrl- self.consoleId = consoleId- userdefaults.set(self.baseURL, forKey: GeofenceProvider.baseUrlKey)- userdefaults.set(self.consoleId, forKey: GeofenceProvider.consoleIdKey)- userdefaults.synchronize()-- return [- DefaultsKey.actionKey: Actions.providerEnable,- DefaultsKey.providerKey: Providers.geofence,- DefaultsKey.hasPermissionKey: checkPermission(),- DefaultsKey.successKey: true- ]- }-- public func disbale()-> [String: Any] {- return [- DefaultsKey.actionKey: "PROVIDER_DISABLE",- DefaultsKey.providerKey: Providers.geofence- ]- }-- public func refreshGeofences() {- fetchGeofences()- }-- func fetchGeofences(callback: (([GeofenceDefinition]) -> ())? = nil) {- if let tkurlRequest = URL(string: "\(baseURL)/\(geofenceFetchEndpoint)\(consoleId)") {- let tkRequest = NSMutableURLRequest(url: tkurlRequest)- tkRequest.httpMethod = "GET"- let sessionConfiguration = URLSessionConfiguration.default- let session = URLSession(configuration: sessionConfiguration, delegate: self, delegateQueue: nil)- let req = session.dataTask(with: tkRequest as URLRequest, completionHandler: { (data, response, error) in- if (data != nil){- guard let geofences = try? JSONDecoder().decode([GeofenceDefinition].self, from: data!) else {- callback?([])- return- }- self.clearAllRegions()- print("Geofences count: \(geofences.count)")- for geofence in geofences {- self.addGeofence(geofence: geofence)- }- callback?(geofences)- } else {- NSLog("error %@", (error! as NSError).localizedDescription)- let error = NSError(domain: "", code: 0, userInfo: [- NSLocalizedDescriptionKey : NSLocalizedString("NoDataReceived", value: "Did not receive any data", comment: "")- ])- print(error)- callback?([])- }- })- req.resume()- } else {- callback?([])- }- }-- private func sendGeofenceRequest(url: URL, data:[String: Any]) {- let request = NSMutableURLRequest(url: url)- request.addValue("application/json", forHTTPHeaderField:"Content-Type");- request.httpMethod = "POST"-- let refreshToken = TokenManager.sharedInstance.refreshToken--- if let postBody = try? JSONSerialization.data(withJSONObject: data, options: []) {- if refreshToken != nil {- ORAssetResoure.sharedInstance.updateAssetAttribute(assetId: consoleId, attributeName: "location", rawJson: postBody)- } else {- ORAssetResoure.sharedInstance.updatePublicAssetAttibute(assetId: consoleId, attributeName: "location", rawJson: postBody)- }- }- }-- public class GeofenceDefinition: NSObject, Decodable {- public var id: String = ""- public var lat: Double = 0.0- public var lng: Double = 0.0- public var radius: Double = 0.0- public var postUrl: String = ""- }-}--extension GeofenceProvider: CLLocationManagerDelegate {- public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {- guard let circularRegion = region as? CLCircularRegion else {return}-- guard let postString = geoPostUrls[circularRegion.identifier] else {- return- }- guard let tkurlRequest = URL(string: "\(baseURL)\(postString)") else { return }-- let postData = [- "type": "Point",- "coordinates": [manager.location?.coordinate.longitude, manager.location?.coordinate.latitude]- ] as [String : Any]-- sendGeofenceRequest(url: tkurlRequest, data: postData)- }-- public func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {- guard let circularRegion = region as? CLCircularRegion else {return}-- guard let postString = geoPostUrls[circularRegion.identifier] else {- return- }- guard let tkurlRequest = URL(string: "\(baseURL)\(postString)") else { return }-- let postData = [- "type": "Point",- "coordinates": [0, 0]- ] as [String : Any]-- sendGeofenceRequest(url: tkurlRequest, data: postData)- }-- public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {- if status != .notDetermined {- initializeCallback?([- DefaultsKey.actionKey: Actions.providerInit,- DefaultsKey.providerKey: Providers.geofence,- DefaultsKey.versionKey: version,- DefaultsKey.requiresPermissionKey: true,- DefaultsKey.hasPermissionKey: checkPermission(),- DefaultsKey.successKey: true- ])- }- }-}diff --git a/console/iOS/ORLib/ORLib/ConsoleProviders/PushNotificationProvider.swift b/console/iOS/ORLib/ORLib/ConsoleProviders/PushNotificationProvider.swiftdeleted file mode 100644index 4a5756d6b..000000000--- a/console/iOS/ORLib/ORLib/ConsoleProviders/PushNotificationProvider.swift+++ /dev/null@@ -1,45 +0,0 @@-//-// PushNotificationProvider.swift-// Eindhoven-//-// Created by Michael Rademaker on 25/05/2018.-// Copyright © 2018 OpenRemote Inc. All rights reserved.-//--import UIKit--public class PushNotificationProvider: NSObject {-- let version = "fcm"-- public override init() {- super.init()- }-- public func initialize() -> [String: Any] {- return [- DefaultsKey.actionKey: Actions.providerInit,- DefaultsKey.providerKey: Providers.push,- DefaultsKey.versionKey: version,- DefaultsKey.requiresPermissionKey: false,- DefaultsKey.successKey: true- ]- }-- public func enable()-> [String: Any] {- return [- DefaultsKey.actionKey: Actions.providerEnable,- DefaultsKey.providerKey: Providers.push,- DefaultsKey.hasPermissionKey: true,- DefaultsKey.successKey: true,- DefaultsKey.dataKey: [DefaultsKey.token: TokenManager.sharedInstance.deviceId]- ]- }-- public func disbale()-> [String: Any] {- return [- DefaultsKey.actionKey: Actions.providerDisable,- DefaultsKey.providerKey: Providers.push- ]- }-}diff --git a/console/iOS/ORLib/ORLib/ORAppDelegate.swift b/console/iOS/ORLib/ORLib/ORAppDelegate.swiftindex 70ae2e7c5..5bd61f7c6 100644--- a/console/iOS/ORLib/ORLib/ORAppDelegate.swift+++ b/console/iOS/ORLib/ORLib/ORAppDelegate.swift@@ -33,25 +33,27 @@ open class ORAppDelegate: UIResponder, UIApplicationDelegate, URLSessionDelegatepublic let internetReachability = Reachability()open func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {- UNUserNotificationCenter.current().delegate = self- let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]- UNUserNotificationCenter.current().requestAuthorization(- options: authOptions,- completionHandler: {_, _ in })-- FirebaseApp.configure()- Messaging.messaging().delegate = self-- application.registerForRemoteNotifications()- NotificationCenter.default.addObserver(self,- selector: #selector(self.reachabilityChanged(note:)),- name: NSNotification.Name.reachabilityChanged,- object: internetReachability)- do {- try internetReachability?.startNotifier()- self.updateReachabilityStatus(reachability: internetReachability!)- } catch {- print("Unable to start notifier")+ // if the app was launched because of geofencing+ if launchOptions?[UIApplicationLaunchOptionsKey.location] != nil {+ // create new GeofenceProvider which creates a CLLocationManager that will receive the location update+ _ = GeofenceProvider()+ } else {+ UNUserNotificationCenter.current().delegate = self++ FirebaseApp.configure()+ Messaging.messaging().delegate = self++ application.registerForRemoteNotifications()+ NotificationCenter.default.addObserver(self,+ selector: #selector(self.reachabilityChanged(note:)),+ name: NSNotification.Name.reachabilityChanged,+ object: internetReachability)+ do {+ try internetReachability?.startNotifier()+ self.updateReachabilityStatus(reachability: internetReachability!)+ } catch {+ print("Unable to start notifier")+ }}return true}@@ -108,16 +110,9 @@ open class ORAppDelegate: UIResponder, UIApplicationDelegate, URLSessionDelegate}open func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {-- if let actionsString = userInfo[DefaultsKey.dataKey] as? String {- if let actionData = actionsString.data(using: .utf8){- if let actionDict = try? JSONSerialization.jsonObject(with: actionData, options: []) as? [[String: String]], actions != nil {- if let action = actionDict[DefaultsKey.actionKey] as? String {- if action == Actions.geofenceRefresh {- (self.window?.rootViewController as! ORViewcontroller).geofenceProvider?.refreshGeofences()- }- }- }+ if let action = userInfo[DefaultsKey.actionKey] as? String {+ if action == Actions.geofenceRefresh {+ (self.window?.rootViewController as! ORViewcontroller).geofenceProvider?.refreshGeofences()}}completionHandler(UIBackgroundFetchResult.newData)@@ -178,45 +173,45 @@ open class ORAppDelegate: UIResponder, UIApplicationDelegate, URLSessionDelegate}extension ORAppDelegate : UNUserNotificationCenterDelegate {-+open func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {completionHandler([.alert, .sound])}open func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {- var assetId : String = ""- var attributeName : String = ""- var rawJson : String = ""- UIApplication.shared.isNetworkActivityIndicatorVisible = true- switch response.actionIdentifier {- case UNNotificationDefaultActionIdentifier,- ActionType.ACTION_DEEP_LINK :- if let urlToOpen = response.notification.request.content.userInfo["appUrl"] as? String {- if urlToOpen.hasPrefix("http") || urlToOpen.hasPrefix("https") {- guard let urlRequest = URL(string:urlToOpen) else { return }- (self.window?.rootViewController as! ORViewcontroller).loadURL(url:urlRequest)- } else {- guard let urlRequest = URL(string:String(format: "%@://%@/%@%@", ORServer.scheme, ORServer.hostURL, ORServer.navigationPath, urlToOpen)) else { return }- (self.window?.rootViewController as! ORViewcontroller).loadURL(url:urlRequest)- }- NSLog("Action asked : %@", response.actionIdentifier)+ var assetId : String = ""+ var attributeName : String = ""+ var rawJson : String = ""+ UIApplication.shared.isNetworkActivityIndicatorVisible = true+ switch response.actionIdentifier {+ case UNNotificationDefaultActionIdentifier,+ ActionType.ACTION_DEEP_LINK :+ if let urlToOpen = response.notification.request.content.userInfo["appUrl"] as? String {+ if urlToOpen.hasPrefix("http") || urlToOpen.hasPrefix("https") {+ guard let urlRequest = URL(string:urlToOpen) else { return }+ (self.window?.rootViewController as! ORViewcontroller).loadURL(url:urlRequest)+ } else {+ guard let urlRequest = URL(string:String(format: "%@://%@/%@%@", ORServer.scheme, ORServer.hostURL, ORServer.navigationPath, urlToOpen)) else { return }+ (self.window?.rootViewController as! ORViewcontroller).loadURL(url:urlRequest)}- case ActionType.ACTION_ACTUATOR :NSLog("Action asked : %@", response.actionIdentifier)+ }+ case ActionType.ACTION_ACTUATOR :+ NSLog("Action asked : %@", response.actionIdentifier)- if let actions = response.notification.request.content.userInfo["actions"] {- assetId = (actions as! Dictionary<String,String>)["assetId"]!- attributeName = (actions as! Dictionary<String,String>)["attributeName"]!- rawJson = (actions as! Dictionary<String,String>)["rawJson"]!- }+ if let actions = response.notification.request.content.userInfo["actions"] {+ assetId = (actions as! Dictionary<String,String>)["assetId"]!+ attributeName = (actions as! Dictionary<String,String>)["attributeName"]!+ rawJson = (actions as! Dictionary<String,String>)["rawJson"]!+ }- if let jsonData = rawJson.data(using: .utf8) {- ORAssetResoure.sharedInstance.updateAssetAttribute(assetId : assetId, attributeName : attributeName, rawJson : jsonData)- }- default : break+ if let jsonData = rawJson.data(using: .utf8) {+ ORAssetResoure.sharedInstance.updateAssetAttribute(assetId : assetId, attributeName : attributeName, rawJson : jsonData)}- completionHandler()+ default : break}+ completionHandler()+ }}extension ORAppDelegate : MessagingDelegate {diff --git a/console/iOS/ORLib/ORLib/ORAssetResource.swift b/console/iOS/ORLib/ORLib/ORAssetResource.swiftdeleted file mode 100644index 150e0ce65..000000000--- a/console/iOS/ORLib/ORLib/ORAssetResource.swift+++ /dev/null@@ -1,60 +0,0 @@-//-// ORAssetResoure.swift-// GoogleToolboxForMac-//-// Created by Michael Rademaker on 04/06/2018.-//--import UIKit--open class ORAssetResoure: NSObject, URLSessionDelegate {-- public static let sharedInstance = ORAssetResoure()-- private override init() {- super.init()- }-- open func updateAssetAttribute(assetId : String, attributeName : String, rawJson : Data) {- UIApplication.shared.isNetworkActivityIndicatorVisible = true- TokenManager.sharedInstance.getAccessToken { (accessTokenResult) in- switch accessTokenResult {- case .Failure(let error) :- UIApplication.shared.isNetworkActivityIndicatorVisible = false- ErrorManager.showError(error: error!)- case .Success(let accessToken) :- self.updateAssetAttribute(assetId: assetId, attributeName: attributeName, accessToken: accessToken, rawJson: rawJson)- }- }- }-- open func updatePublicAssetAttibute(assetId : String, attributeName : String, rawJson : Data) {- updateAssetAttribute(assetId: assetId, attributeName: attributeName, accessToken: nil, rawJson: rawJson)- }-- private func updateAssetAttribute(assetId : String, attributeName : String, accessToken :String?, rawJson : Data) {- guard let urlRequest = URL(string: String(String(format: "\(ORServer.scheme)://%@/%@/asset/%@/attribute/%@", ORServer.hostURL, ORServer.realm, assetId, attributeName))) else { return }- let request = NSMutableURLRequest(url: urlRequest)- request.httpMethod = "PUT"- request.addValue("application/json", forHTTPHeaderField: "Content-Type")- request.httpBody = rawJson- if let token = accessToken {- request.addValue(String(format:"Bearer %@", token), 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)- }- }- })- reqDataTask.resume()- }-}diff --git a/console/iOS/ORLib/ORLib/ORViewController.swift b/console/iOS/ORLib/ORLib/ORViewController.swiftindex bdad4f231..c1b4ddf7f 100644--- a/console/iOS/ORLib/ORLib/ORViewController.swift+++ b/console/iOS/ORLib/ORLib/ORViewController.swift@@ -41,8 +41,8 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMesssuper.viewWillAppear(animated)self.configureAccess()}-- open override func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {++ open func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {let jsonDictionnary = message.body as? [String : Any]if let type = jsonDictionnary?["type"] as? String {switch (type) {@@ -56,12 +56,13 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMessif provider == Providers.push {if action == Actions.providerInit {pushProvider = PushNotificationProvider()- let initalizeData = pushProvider!.initialize()- sendData(data: initalizeData)+ pushProvider!.initialize(callback: { initalizeData in+ self.sendData(data: initalizeData)+ })} else if action == Actions.providerEnable {- if let enableData = pushProvider?.enable() {- sendData(data: enableData)- }+ pushProvider?.enable(callback: { enableData in+ self.sendData(data: enableData)+ })} else if action == Actions.providerDisable {if let disableData = pushProvider?.disbale() {sendData(data: disableData)@@ -71,19 +72,17 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMessif provider == Providers.geofence {if action == Actions.providerInit {geofenceProvider = GeofenceProvider()- geofenceProvider!.initialize { initalizeData in- self.sendData(data: initalizeData)- }+ let initializeData = geofenceProvider!.initialize()+ sendData(data: initializeData)} else if action == Actions.providerEnable {if let data = postMessageDict[DefaultsKey.dataKey] as? [String: String] {if let consoleId = data["consoleId"] {- if let enableData = geofenceProvider?.enable(baseUrl: "\(ORServer.baseUrl)\(ORServer.realm)", consoleId: consoleId) {- sendData(data: enableData)-+ geofenceProvider?.enable(baseUrl: "\(ORServer.baseUrl)\(ORServer.realm)", consoleId: consoleId, callback: { enableData in+ self.sendData(data: enableData)DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) {self.geofenceProvider?.fetchGeofences()}- }+ })}}} else if action == Actions.geofenceRefresh {@@ -110,9 +109,11 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMesslet theJSONText = String(data: theJSONData,encoding: .utf8)let returnMessage = "openremote.INSTANCE.console.handleProviderResponse('\(theJSONText ?? "null")')"- myWebView?.evaluateJavaScript("\(returnMessage)", completionHandler: { (any, error) in- print("JSON string = \(theJSONText!)")- })+ DispatchQueue.main.async {+ self.myWebView?.evaluateJavaScript("\(returnMessage)", completionHandler: { (any, error) in+ print("JSON string = \(theJSONText!)")+ })+ }}}diff --git a/console/iOS/ORLib/ORLib/ProjectConstants.swift b/console/iOS/ORLib/ORLib/ProjectConstants.swiftindex 9e3bf2686..c8ba0f43a 100644--- a/console/iOS/ORLib/ORLib/ProjectConstants.swift+++ b/console/iOS/ORLib/ORLib/ProjectConstants.swift@@ -26,6 +26,7 @@ public enum ORServer {public static var initialPath = "console/\(ORServer.realm)/"public static var navigationPath = "console/\(ORServer.realm)/"public static var realm = "openremote"+ public static var baseUrl = "\(ORServer.scheme)://\(ORServer.hostURL)/"public static var apiTestResource = String(format:"\(ORServer.scheme)://%@/%@/notification/alert",ORServer.hostURL,ORServer.realm)public static var registerDeviceResource = String(format:"\(ORServer.scheme)://%@/%@/notification/token",ORServer.hostURL,ORServer.realm)