Я не могу позвонить snapshot.documentChanges
в addSnapshotListener
Сказано Value of type 'DocumentSnapshot' has no member 'documentChanges'
Xcode 10.2, Swift 5, Firestore 5.10.0 и другие сведения о других библиотеках ниже
fileprivate func setupSnapshotListener() {
let coupleId = "B9C950640E1B3740E98ACB93E669C65766F6670DD1609BA91FF41052BA48C6F3"
let ref = Firestore.firestore().collection("couples").document(coupleId).collection("vibrations").document("vibrationStatus")
ref.addSnapshotListener { (querySnapshot, err) in
guard let snapshot = querySnapshot else {
print(err)
return
}
snapshot.documentChanges.forEach { diff in
if (diff.type == .added) {
print("New city: \(diff.document.data())")
}
if (diff.type == .modified) {
print("Modified city: \(diff.document.data())")
}
if (diff.type == .removed) {
print("Removed city: \(diff.document.data())")
}
}
}
}
Podfile
pod 'Firebase/Firestore’,’~>5.10.0’
pod 'Firebase/Auth’,’~>5.10.0’
pod 'Firebase/Storage’,’~>5.10.0’
pod 'Firebase/Core’
pod 'GoogleAppMeasurement', '~> 5.2.0'
pod 'JGProgressHUD','~>2.0.3'
pod 'GoogleUtilities'
Я ожидал использовать addListener
, как сказал Google Firebase Document, но я не могу позвонить documentChanges
!!