React-native-firebase: 馃敟 ServerTimestamp isn't working with arrayUnion

Created on 14 Jan 2019  路  4Comments  路  Source: invertase/react-native-firebase

Issue

FieldValue serverTimestamp inside arrayUnion isn't working. Outside arrayUnion everything works fine.
await messageRef.update({array: firebase.firestore.FieldValue.arrayUnion({ message, timestamp: firebase.firestore.FieldValue.serverTimestamp(), senderId }) })

slika

Also, on version 5.2.0 same code reproduce this :

slika1


Environment

  • Platform that you're experiencing the issue on:

    • [ ] iOS

    • [ ] Android

    • [ ] iOS but have not tested behavior on Android

    • [x] Android but have not tested behavior on iOS

    • [ ] Both

  • If known, the version of the platform are you experiencing the issue on:

    • API 27

  • Operating System:

    • [ ] MacOS, version: N/A

    • [x] Windows, version: Windows_NT x64 10.0.17134

    • [ ] Other, please specify: N/A

  • Build Tools:

    • Android Studio 3.1.4

  • React Native version:

    • 0.57.8

  • React Native Firebase library version:

    • 5.1.1

  • Firebase module(s) you're using that has the issue:

    • [ ] Authentication

    • [ ] Analytics

    • [x] Cloud Firestore

    • [ ] Cloud Messaging (FCM)

    • [ ] Crashlytics

    • [ ] Dynamic Links

    • [ ] Functions Callable

    • [ ] Invites

    • [ ] Instance ID

    • [ ] Notifications

    • [ ] Performance Monitoring

    • [ ] Realtime Database

    • [ ] Remote Config

    • [ ] Storage

  • Are you using TypeScript?

    • [x] No

    • [ ] Yes, version: N/A

  • Are you using Expo, e.g. ExpoKit?

    • [x] No

    • [ ] Yes, I've _not_ ejected

    • [ ] Yes, but I have ejected to ExpoKit

    • [ ] Yes, but I have ejected to vanilla React Native

    • Expo version: N/A

Most helpful comment

@manicantic hey, sorry I forgot to mention, the fix for v5.2.0 means that data gets passed correctly to Firestore - now that it's correctly passed it will give you that Error as this is the correct behaviour, none of the Firebase SDKs support serverTimestamp in arrayUnion/remove yet. E.g.: https://github.com/firebase/firebase-admin-node/issues/336

References and other values work fine.

All 4 comments

Hey @manicantic this was resolved in v5.2.0, please could you upgrade, thanks.

Changelog & upgrade guide here: https://rnfirebase.io/docs/v5.x.x/releases/v5.2.0

Hey @Salakar , I tried 5.2.0 and still got an error. If I have update with arrayUnion and serverTimestamp with transaction app instantly crashes ( code : await transaction.update(messageRef, { array: firebase .firestore .FieldValue .arrayUnion({ message, timestamp: firebase .firestore .FieldValue .serverTimestamp(), senderId }) }) ) ), and if update wihtout transaction I get this error :
screenshot_2019-01-14-22-58-49 Code for this : await messageRef.update({ array: firebase .firestore .FieldValue .arrayUnion({ message, timestamp: firebase .firestore .FieldValue .serverTimestamp(), senderId }) }) .
And first time I updated to 5.2.0 ( while I was writing this issue ) I updated document and firestore looked like this:

Also my app level build.gradle details :
implementation "com.google.firebase:firebase-core:16.0.6" implementation "com.google.firebase:firebase-auth:16.1.0" implementation "com.google.firebase:firebase-firestore:17.1.5"

@manicantic hey, sorry I forgot to mention, the fix for v5.2.0 means that data gets passed correctly to Firestore - now that it's correctly passed it will give you that Error as this is the correct behaviour, none of the Firebase SDKs support serverTimestamp in arrayUnion/remove yet. E.g.: https://github.com/firebase/firebase-admin-node/issues/336

References and other values work fine.

@Salakar "none of the Firebase SDKs support serverTimestamp in arrayUnion/remove yet"

"YET", does that mean that it will be supported eventually?

Was this page helpful?
0 / 5 - 0 ratings