firebase / firebase/firebase-ios-sdk
Firestore QuerySnapshot.documentChanges(includeMetadataChanges: false) always returns DocumentChange with only metadata changes
- Dominant language
- C++
- Stars
- 6.7k
- Forks
- 1.8k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 72
Description
### Description
In Firestore's `QuerySnapshot#documentChanges` API at https://github.com/firebase/firebase-ios-sdk/blob/03ce722d0e511a9f606ea95077d416aaaea4bdb6/Firestore/Source/Public/FirebaseFirestore/FIRQuerySnapshot.h#L68, it allows us to specify whether to include document changes with only metadata changes. However, from my observation, no matter this is set to true or false, it always returns document change even if there is only metadata change. This make it impossible for us to know which document change actually comes from the server.
I've tested the same piece of code in both Android and iOS. In Android, this behaviour works as expected, when I do `querySnapshot.getDocumentChanges(MetadataChanges.EXCLUDE)`, it will return 0 documentChange if there is only metadata changed.
### Reproducing the issue
For both Android and iOS, I'm using the exact same setup, listening to same collection with the same query, with `includeMetadataChanges` set to `true`.
Here's my code in iOS that processes the received `QuerySnapshot` and its log output when I write a new document locally:


Here's my code in Android that processes the received `QuerySnapshot` and its log output when I write a new document locally:


### Firebase SDK Version
10.23.1
### Xcode Version
15.2
### Installation Method
Swift Package Manager
### Firebase Product(s)
Firestore
### Targeted Platforms
iOS
### Relevant Log Output
_No response_
### If using Swift Package Manager, the project's Package.resolved
Expand Package.resolved snippet
```json
Replace this line with the contents of your Package.resolved.
```
### If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock snippet
```yml
Replace this line with the contents of your Podfile.lock!
```
Contributor guide
Assessment
This issue has not been assessed yet.