From 66f3aeda1663e0bdcdd4d46cdd3dba3fdf68b4c3 Mon Sep 17 00:00:00 2001 From: Riz Date: Tue, 19 Sep 2017 12:58:58 -0700 Subject: Log direct-channel state changes to console (#287) --- Example/Messaging/App/iOS/AppDelegate.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Example/Messaging') diff --git a/Example/Messaging/App/iOS/AppDelegate.swift b/Example/Messaging/App/iOS/AppDelegate.swift index 3f81784..4f8e504 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)") + } +} -- cgit v1.2.3