Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created May 11, 2019 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quangtqag/ba57109a74bbd5ce42907311cd172cc1 to your computer and use it in GitHub Desktop.
Save quangtqag/ba57109a74bbd5ce42907311cd172cc1 to your computer and use it in GitHub Desktop.
func send(candidate rtcIceCandidate: RTCIceCandidate, to person: String) {
do {
let dataMessage = try self.encoder.encode(IceCandidate(from: rtcIceCandidate))
let dict = try JSONSerialization.jsonObject(with: dataMessage, options: .allowFragments) as! [String: Any]
Firestore.firestore()
.collection(person)
.document("candidate")
.collection("candidates")
.addDocument(data: dict) { (err) in
if let err = err {
print("Error send candidate: \(err)")
} else {
print("Candidate sent!")
}
}
}
catch {
debugPrint("Warning: Could not encode candidate: \(error)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment