Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Updated last thing for cocoapod

Michael Rademaker7f5d8fdbf0fc
diff --git a/console/iOS/ORLib/ORLib.podspec b/console/iOS/ORLib/ORLib.podspec
index 08c9f5100..2770f6fd2 100644
--- a/console/iOS/ORLib/ORLib.podspec
+++ b/console/iOS/ORLib/ORLib.podspec
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.name = "ORLib"
s.summary = "The OpenRemote library to create console apps."
s.requires_arc = true
- s.version = '1.2.1'
+ s.version = '1.2.0'
s.authors = 'OpenRemote'
s.homepage = "http://www.openremote.io"
s.source = { :git => 'https://github.com/openremote/openremote.git', :tag => 'cocoapod' + s.version.to_s }
diff --git a/console/iOS/ORLib/ORLib/GeofenceProvider.swift b/console/iOS/ORLib/ORLib/GeofenceProvider.swift
index 769dfcd85..4e897ef71 100644
--- a/console/iOS/ORLib/ORLib/GeofenceProvider.swift
+++ b/console/iOS/ORLib/ORLib/GeofenceProvider.swift
@@ -37,10 +37,10 @@ public class GeofenceProvider: NSObject, URLSessionDelegate {
DefaultsKey.actionKey: Actions.providerInit,
DefaultsKey.providerKey: Providers.geofence,
DefaultsKey.versionKey: version,
- DefaultsKey.requiresPermissionKey: false,
- DefaultsKey.hasPermissionKey: true,
+ DefaultsKey.requiresPermissionKey: true,
+ DefaultsKey.hasPermissionKey: checkPermission(),
DefaultsKey.successKey: true,
- DefaultsKey.enabledKey: true
+ DefaultsKey.enabledKey: false
]
}
diff --git a/console/iOS/ORLib/ORLib/ORViewController.swift b/console/iOS/ORLib/ORLib/ORViewController.swift
index 036969752..638c5b2ff 100644
--- a/console/iOS/ORLib/ORLib/ORViewController.swift
+++ b/console/iOS/ORLib/ORLib/ORViewController.swift
@@ -59,12 +59,10 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMess
self.sendData(data: initalizeData)
})
} else if action == Actions.providerEnable {
- if let data = postMessageDict[DefaultsKey.dataKey] as? [String: String] {
- if let consoleId = data[GeofenceProvider.consoleIdKey] {
- pushProvider?.enable(consoleId: consoleId, callback: { enableData in
- self.sendData(data: enableData)
- })
- }
+ if let consoleId = postMessageDict[GeofenceProvider.consoleIdKey] as? String {
+ pushProvider?.enable(consoleId: consoleId, callback: { enableData in
+ self.sendData(data: enableData)
+ })
}
} else if action == Actions.providerDisable {
if let disableData = pushProvider?.disbale() {
@@ -77,15 +75,13 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMess
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[GeofenceProvider.consoleIdKey] {
- geofenceProvider?.enable(baseUrl: "\(ORServer.baseUrl)api/\(ORServer.realm)", consoleId: consoleId, callback: { enableData in
- self.sendData(data: enableData)
- DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) {
- self.geofenceProvider?.fetchGeofences()
- }
- })
- }
+ if let consoleId = postMessageDict[GeofenceProvider.consoleIdKey] as? String {
+ geofenceProvider?.enable(baseUrl: "\(ORServer.baseUrl)api/\(ORServer.realm)", consoleId: consoleId, callback: { enableData in
+ self.sendData(data: enableData)
+ DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) {
+ self.geofenceProvider?.fetchGeofences()
+ }
+ })
}
} else if action == Actions.geofenceRefresh {
geofenceProvider?.refreshGeofences()
@@ -104,17 +100,13 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMess
sendData(data: enableData)
}
} else if action == Actions.store {
- if let data = postMessageDict[DefaultsKey.dataKey] as? [String: String] {
- if let key = data["key"] {
- storageProvider?.store(key: key, data: data["value"])
- }
+ if let key = postMessageDict["key"] as? String {
+ storageProvider?.store(key: key, data: postMessageDict["value"] as? String)
}
} else if action == Actions.retrieve {
- if let data = postMessageDict[DefaultsKey.dataKey] as? [String: String] {
- if let key = data["key"] {
- if let retrieveData = storageProvider?.retrieve(key: key) {
- sendData(data: retrieveData)
- }
+ if let key = postMessageDict["key"] as? String {
+ if let retrieveData = storageProvider?.retrieve(key: key) {
+ sendData(data: retrieveData)
}
}
} else if action == Actions.providerDisable {
@@ -132,13 +124,13 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMess
}
}
- open func sendData(data: [String: Any]) {
+ open func sendData(data: [String: Any?]) {
if let theJSONData = try? JSONSerialization.data(
withJSONObject: data,
options: []) {
let theJSONText = String(data: theJSONData,
encoding: .utf8)
- let returnMessage = "openremote.INSTANCE.console.handleProviderResponse('\(theJSONText ?? "null")')"
+ let returnMessage = "OpenRemoteConsole._handleProviderResponse('\(theJSONText ?? "null")')"
DispatchQueue.main.async {
self.myWebView?.evaluateJavaScript("\(returnMessage)", completionHandler: { (any, error) in
print("JSON string = \(theJSONText!)")
@@ -252,7 +244,12 @@ open class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMess
userController.addUserScript(userScript)
webCfg.userContentController = userController;
- let sbHeight = UIApplication.shared.statusBarFrame.height
+ let sbHeight: CGFloat
+ if #available(iOS 11.0, *) {
+ sbHeight = UIApplication.shared.keyWindow?.safeAreaInsets.top ?? UIApplication.shared.statusBarFrame.height
+ } else {
+ sbHeight = UIApplication.shared.statusBarFrame.height
+ }
let webFrame = CGRect(x : 0,y : sbHeight,width : view.frame.size.width,height : view.frame.size.height - sbHeight)
myWebView = WKWebView(frame: webFrame, configuration: webCfg)
myWebView?.autoresizingMask = [.flexibleWidth, .flexibleHeight];
diff --git a/console/iOS/ORLib/ORLib/PushNotificationProvider.swift b/console/iOS/ORLib/ORLib/PushNotificationProvider.swift
index 3b63c049d..c1c228e17 100644
--- a/console/iOS/ORLib/ORLib/PushNotificationProvider.swift
+++ b/console/iOS/ORLib/ORLib/PushNotificationProvider.swift
@@ -19,7 +19,7 @@ public class PushNotificationProvider: NSObject {
super.init()
}
- public func initialize(callback:@escaping ([String: Any]) ->(Void)) {
+ public func initialize(callback:@escaping ([String: Any?]) ->(Void)) {
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
switch settings.authorizationStatus {
@@ -30,7 +30,8 @@ public class PushNotificationProvider: NSObject {
DefaultsKey.versionKey: self.version,
DefaultsKey.hasPermissionKey: true,
DefaultsKey.requiresPermissionKey: true,
- DefaultsKey.successKey: true
+ DefaultsKey.successKey: true,
+ DefaultsKey.enabledKey: false
])
case .denied:
@@ -40,7 +41,8 @@ public class PushNotificationProvider: NSObject {
DefaultsKey.versionKey: self.version,
DefaultsKey.hasPermissionKey: false,
DefaultsKey.requiresPermissionKey: true,
- DefaultsKey.successKey: true
+ DefaultsKey.successKey: true,
+ DefaultsKey.enabledKey: false
])
case .notDetermined:
@@ -48,9 +50,10 @@ public class PushNotificationProvider: NSObject {
DefaultsKey.actionKey: Actions.providerInit,
DefaultsKey.providerKey: Providers.push,
DefaultsKey.versionKey: self.version,
- DefaultsKey.hasPermissionKey: false,
+ DefaultsKey.hasPermissionKey: nil,
DefaultsKey.requiresPermissionKey: true,
- DefaultsKey.successKey: true
+ DefaultsKey.successKey: true,
+ DefaultsKey.enabledKey: false
])
}
}
diff --git a/console/iOS/ORLib/ORLib/StorageProvider.swift b/console/iOS/ORLib/ORLib/StorageProvider.swift
index 665290b5b..2ccbe67a7 100644
--- a/console/iOS/ORLib/ORLib/StorageProvider.swift
+++ b/console/iOS/ORLib/ORLib/StorageProvider.swift
@@ -16,10 +16,10 @@ class StorageProvider: NSObject {
DefaultsKey.actionKey: Actions.providerInit,
DefaultsKey.providerKey: Providers.storage,
DefaultsKey.versionKey: "1.0.0",
- DefaultsKey.requiresPermissionKey: true,
+ DefaultsKey.requiresPermissionKey: false,
DefaultsKey.hasPermissionKey: true,
DefaultsKey.successKey: true,
- DefaultsKey.enabledKey: false
+ DefaultsKey.enabledKey: true
]
}