title: How to implement Server-Sent Events on IOS using Firebase?
body: <p>I am trying to listen the firebase events using rest api.The problem is the callback method is not called. I am using <a href="https://github.com/inaka/EventSource" rel="noreferrer">EventSource</a> for this purpose.Is this the correct way to listen the events?</p>
  
  <pre><code>Auth.auth().currentUser?.getIDTokenForcingRefresh(true, completion: { (token, error) in
      let server : String =  "https://project-XXXXX.firebaseio.com/.json?auth=\(token!)"
  
      let eventSource: EventSource = EventSource(url: server)
      eventSource.onOpen {
          // When opened
          debugPrint("eventSource open")
      }
  
      eventSource.onError { (error) in
          // When errors
          debugPrint("error = \(error?.localizedDescription)")
      }
      eventSource.onMessage { (id, event, data) in
          debugPrint("data = \(data)")
          // Here you get an event without event name!
      }
  
      eventSource.addEventListener("child_added") { (id, event, data) in
          debugPrint("data = \(data)")
          // Here you get an event 'event-name'
      }
  })
  </code></pre>