Skip to content

armgit / core

Public Imported from GitHub
0

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

iOS console : notification changes

William Balcaenb6dcbfad2a99
diff --git a/console/iOS/NotificationExtension/Constants.swift b/console/iOS/NotificationExtension/Constants.swift
index acf0e9e33..a4654aca1 100644
--- a/console/iOS/NotificationExtension/Constants.swift
+++ b/console/iOS/NotificationExtension/Constants.swift
@@ -17,3 +17,11 @@ struct DefaultsKey {
struct AppGroup {
static let entitlement = "group.org.openremote.console"
}
+
+enum Server {
+ static let hostURL = "192.168.0.138"
+ static let port = "8080"
+ static let initialPath = String(format:"console/%@/index.html",Server.realm)
+ static let realm = "blok61"
+ static let apiTestResource = String(format:"http://%@:%@/%@/asset",Server.hostURL,Server.port,Server.realm)
+}
diff --git a/console/iOS/NotificationExtension/NotificationService.swift b/console/iOS/NotificationExtension/NotificationService.swift
index 72c482658..7aa71d836 100644
--- a/console/iOS/NotificationExtension/NotificationService.swift
+++ b/console/iOS/NotificationExtension/NotificationService.swift
@@ -23,7 +23,8 @@ class NotificationService: UNNotificationServiceExtension {
defaults?.synchronize()
bestAttemptContent.title = "You received an alarm from blok61 :"
bestAttemptContent.body = "payload received from backend..."
- guard let tkurlRequest = URL(string: "http://192.168.99.100:8080/auth/realms/blok61/protocol/openid-connect/token") else { return }
+ guard let tkurlRequest = URL(string:String(format: "http://%@:%@/auth/realms/%@/protocol/openid-connect/token",Server.hostURL, Server.port,Server.realm))
+ else { return }
let tkRequest = NSMutableURLRequest(url: tkurlRequest)
tkRequest.addValue("application/x-www-form-urlencoded", forHTTPHeaderField:"Content-Type");
tkRequest.httpMethod = "POST"
@@ -36,7 +37,7 @@ class NotificationService: UNNotificationServiceExtension {
do {
let jsonDictionnary: Dictionary = try JSONSerialization.jsonObject(with: data!, options: []) as! [String:Any]
if ((jsonDictionnary["access_token"]) != nil) {
- guard let urlRequest = URL(string: "http://192.168.99.100:8080/blok61/asset") else { return }
+ guard let urlRequest = URL(string: Server.apiTestResource) else { return }
let request = NSMutableURLRequest(url: urlRequest)
request.addValue(String(format:"Bearer %@", jsonDictionnary["access_token"] as! String), forHTTPHeaderField: "Authorization")
let sessionConfiguration = URLSessionConfiguration.default
diff --git a/console/iOS/console/AppDelegate.swift b/console/iOS/console/AppDelegate.swift
index 93dc3c763..8a02e652d 100644
--- a/console/iOS/console/AppDelegate.swift
+++ b/console/iOS/console/AppDelegate.swift
@@ -132,7 +132,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
else
{
if let token = FIRInstanceID.instanceID().token() {
- NSLog("Connected to FCM. Token is ",token as String)
+ NSLog("Connected to FCM. Token is %@",token as String)
} else {
NSLog("Connected to FCM. Token is currently nil")
}
diff --git a/console/iOS/console/Constants.swift b/console/iOS/console/Constants.swift
index c7e45fde2..12ecb487a 100644
--- a/console/iOS/console/Constants.swift
+++ b/console/iOS/console/Constants.swift
@@ -9,7 +9,7 @@
import Foundation
enum Server {
- static let hostURL = "192.168.99.100"
+ static let hostURL = "192.168.0.138"
static let port = "8080"
static let initialPath = String(format:"console/%@/index.html",Server.realm)
static let realm = "blok61"