aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Messaging
diff options
context:
space:
mode:
authorGravatar Riz <rsattar@gmail.com>2017-09-19 12:58:58 -0700
committerGravatar GitHub <noreply@github.com>2017-09-19 12:58:58 -0700
commit66f3aeda1663e0bdcdd4d46cdd3dba3fdf68b4c3 (patch)
treeea82af27924ce68520e034e64510f3a17e19dcab /Example/Messaging
parent9447e72cab40c9ea59e49a726d2890bcf356d38a (diff)
Log direct-channel state changes to console (#287)
Diffstat (limited to 'Example/Messaging')
-rw-r--r--Example/Messaging/App/iOS/AppDelegate.swift11
1 files changed, 11 insertions, 0 deletions
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)")
+ }
+}