     
     func room(_ room: TVIRoom, didDisconnectWithError error: Error?) {
         logMessage(messageText: "Disconncted from room \(room.name), error = \(String(describing: error))")
-        
+
+        if !self.userInitiatedDisconnect, let uuid = room.uuid, let error = error {
+            var reason = CXCallEndedReason.remoteEnded
+
+            if (error as NSError).code != TVIError.roomRoomCompletedError.rawValue {
+                reason = .failed
+            }
+
+            self.callKitProvider.reportCall(with: uuid, endedAt: nil, reason: reason)
+        }
+
         self.cleanupRemoteParticipant()
         self.room = nil
         self.showRoomUI(inRoom: false)
         self.callKitCompletionHandler = nil
+        self.userInitiatedDisconnect = false
     }
     
     func room(_ room: TVIRoom, didFailToConnectWithError error: Error) {

    let callKitProvider: CXProvider
    let callKitCallController: CXCallController
    var callKitCompletionHandler: ((Bool)->Swift.Void?)? = nil

    // MARK: UI Element Outlets and handles
    @IBOutlet weak var connectButton: UIButton!

    @IBAction func disconnect(sender: AnyObject) {
        if let room = room, let uuid = room.uuid {
            logMessage(messageText: "Attempting to disconnect from room \(room.name)")
            userInitiatedDisconnect = true
            performEndCallAction(uuid: uuid)
        }
    }
