From 95f4c2c99aee7d3bedea83f3f62c7d98a8221504 Mon Sep 17 00:00:00 2001 From: Rizwan Sattar Date: Mon, 18 Sep 2017 14:47:46 -0700 Subject: [PATCH 1/2] Log direct-channel state changes to console --- Example/Messaging/App/iOS/AppDelegate.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Example/Messaging/App/iOS/AppDelegate.swift b/Example/Messaging/App/iOS/AppDelegate.swift index 3f81784d426..cbb89aa070b 100644 --- a/Example/Messaging/App/iOS/AppDelegate.swift +++ b/Example/Messaging/App/iOS/AppDelegate.swift @@ -51,6 +51,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { FirebaseApp.configure() Messaging.messaging().delegate = self Messaging.messaging().shouldEstablishDirectChannel = true + // Just for logging to the console when we establish/tear down our socket connection. + listenForDirectChannelStateChanges(); NotificationsController.configure() @@ -126,3 +128,12 @@ extension AppDelegate: MessagingDelegate { } } +extension AppDelegate { + func listenForDirectChannelStateChanges() { + NotificationCenter.default.addObserver(self, selector: #selector(onMessagingDirectChannelStateChanged(_:)), name: .MessagingConnectionStateChanged, object: nil) + } + + func onMessagingDirectChannelStateChanged(_ notification: Notification) { + print("FCM Direct Channel Established: \(Messaging.messaging().isDirectChannelEstablished)") + } +} From fc00d7ae94ea822ca83bb976305291d8815153bc Mon Sep 17 00:00:00 2001 From: Rizwan Sattar Date: Tue, 19 Sep 2017 11:18:59 -0700 Subject: [PATCH 2/2] Remove trailing space --- Example/Messaging/App/iOS/AppDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Messaging/App/iOS/AppDelegate.swift b/Example/Messaging/App/iOS/AppDelegate.swift index cbb89aa070b..4f8e5046142 100644 --- a/Example/Messaging/App/iOS/AppDelegate.swift +++ b/Example/Messaging/App/iOS/AppDelegate.swift @@ -132,7 +132,7 @@ extension AppDelegate { func listenForDirectChannelStateChanges() { NotificationCenter.default.addObserver(self, selector: #selector(onMessagingDirectChannelStateChanged(_:)), name: .MessagingConnectionStateChanged, object: nil) } - + func onMessagingDirectChannelStateChanged(_ notification: Notification) { print("FCM Direct Channel Established: \(Messaging.messaging().isDirectChannelEstablished)") }