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 : code cleaning

William Balcaen588e04f20804
diff --git a/console/iOS/NotificationExtension/NotificationService.swift b/console/iOS/NotificationExtension/NotificationService.swift
index 4d29a522f..72c482658 100644
--- a/console/iOS/NotificationExtension/NotificationService.swift
+++ b/console/iOS/NotificationExtension/NotificationService.swift
@@ -16,7 +16,7 @@ class NotificationService: UNNotificationServiceExtension {
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
- print("NotifExtension Change content ",bestAttemptContent?.userInfo ?? "")
+ NSLog("NotifExtension Change content : %@ ", bestAttemptContent?.userInfo ?? "")
if let bestAttemptContent = bestAttemptContent {
// Call backend to get payload and adapt title, body and actions
let defaults = UserDefaults(suiteName: AppGroup.entitlement)
@@ -81,7 +81,7 @@ class NotificationService: UNNotificationServiceExtension {
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
- print("NotifExtension Time has expired")
+ NSLog("NotifExtension Time has expired")
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
bestAttemptContent.title = "You received an alarm from blok61 :"
bestAttemptContent.body = "Please open application to check what's happening"
diff --git a/console/iOS/console/AppDelegate.swift b/console/iOS/console/AppDelegate.swift
index a56138568..93dc3c763 100644
--- a/console/iOS/console/AppDelegate.swift
+++ b/console/iOS/console/AppDelegate.swift
@@ -31,7 +31,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
options: authOptions,
completionHandler: {_, _ in })
- FIRMessaging.messaging().remoteMessageDelegate = self
+ //FIRMessaging.messaging().remoteMessageDelegate = self
FIRApp.configure()
@@ -95,12 +95,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
// Print full message.
- print(userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
//self.scheduleLocalNotification()
- print(userInfo)
completionHandler(UIBackgroundFetchResult.noData)
}
@@ -111,7 +109,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
- print("Action asked : ",response.actionIdentifier)
+ NSLog("Action asked : %@",response.actionIdentifier)
}
@@ -129,14 +127,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
FIRMessaging.messaging().connect { (error) in
if (error != nil)
{
- print("Unable to connect with FCM. \(error)")
+ NSLog("Unable to connect with FCM. \(error)")
}
else
{
if let token = FIRInstanceID.instanceID().token() {
- print("Connected to FCM. Token is ",token as String)
+ NSLog("Connected to FCM. Token is ",token as String)
} else {
- print("Connected to FCM. Token is currently nil")
+ NSLog("Connected to FCM. Token is currently nil")
}
}
}
@@ -144,10 +142,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
func tokenRefreshNotification(notification: NSNotification)
{
- if let refreshedToken = FIRInstanceID.instanceID().token()
- {
- print("InstanceID token: \(refreshedToken)")
- }
// Connect to FCM since connection may have failed when attempted before having a token.
connectToFcm()
}
@@ -214,11 +208,3 @@ func setActions() {
}
-
-extension AppDelegate : FIRMessagingDelegate {
- // Receive data message on iOS 10 devices while app is in the foreground.
- func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
- print(remoteMessage.appData)
- }
-}
-
diff --git a/console/iOS/console/TokenManager.swift b/console/iOS/console/TokenManager.swift
index fb6cf4321..ce48763e5 100644
--- a/console/iOS/console/TokenManager.swift
+++ b/console/iOS/console/TokenManager.swift
@@ -42,7 +42,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationD
}
func authenticate() {
- print("authenticate")
+ NSLog("authenticate")
let defaults = UserDefaults(suiteName: AppGroup.entitlement)
let webCfg:WKWebViewConfiguration = WKWebViewConfiguration()
@@ -54,7 +54,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationD
var exec_template = "var iOSToken"
if let offlineToken = defaults?.object(forKey: DefaultsKey.offlineToken) {
- print("offlinetoken exists")
+ NSLog("offlinetoken exists")
let refreshToken = defaults?.object(forKey: DefaultsKey.refreshToken)
let idToken = defaults?.object(forKey: DefaultsKey.idToken)
exec_template = String(format: "var iOSToken = \"%@\"; var iOSRefreshToken = \"%@\"; var iOSTokenId = \"%@\";", offlineToken as! String, refreshToken as! String, idToken as! String)
@@ -115,7 +115,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationD
let alertAction = UIAlertAction(title: "Done", style: .cancel) { (action) in
completionHandler()
}
- print("javascript message %@",message)
+ NSLog("javascript message %@",message)
alertView.addAction(alertAction)
viewController.present(alertView, animated: true, completion: nil)
}
@@ -128,7 +128,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationD
}
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
- print("navigation failed %@",error)
+ NSLog("navigation failed %@",error as NSError)
let errorCode = (error as NSError).code
if errorCode != NSURLErrorCancelled {
NSLog("error %@", error.localizedDescription)
@@ -139,7 +139,7 @@ class TokenManager:NSObject, WKScriptMessageHandler, WKUIDelegate, WKNavigationD
}
func showError(error : Error) {
- print("showing error %@",error)
+ NSLog("showing error %@",error as NSError)
let alertVC = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.alert)
let alertAction = UIAlertAction(title: "Done", style: .cancel) { (action) in
self.viewController.dismiss(animated: true, completion: nil)