我无法在foo
中致电snapshot.documentChanges
它说addSnapshotListener
Xcode 10.2,Swift 5,Firestore 5.10.0以及有关其他库的更多信息都在下面
Value of type 'DocumentSnapshot' has no member 'documentChanges'
Podfile
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())")
}
}
}
}
我希望像Google Firebase Document所说的那样使用 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
!