Skip to content

Commit

Permalink
Log direct-channel state changes to console (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsattar authored Sep 19, 2017
1 parent 9447e72 commit 66f3aed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Example/Messaging/App/iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)")
}
}

0 comments on commit 66f3aed

Please sign in to comment.