react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

🔥 ServerTimestamp isn't working with arrayUnion

Open manicantic opened this issue 7 years ago • 8 comments

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

manicantic avatar Jan 14 '19 19:01 manicantic

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

Salakar avatar Jan 14 '19 20:01 Salakar

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 avatar Jan 14 '19 22:01 manicantic

@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 avatar Jan 14 '19 23:01 Salakar

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

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

julienreszka avatar Sep 10 '19 20:09 julienreszka

Not supported yet unfortunately!

edwardoverthere avatar Jun 27 '22 05:06 edwardoverthere

still not supported yet unfortunately

Asanta4 avatar Jul 13 '24 12:07 Asanta4

so is there a workaround? How do I add a server timestamp to an array?

jdboris avatar Jul 21 '24 10:07 jdboris

I find it absolutely ridiculous that there is no mention of this in the documentation... what a frustrating afternoon. This issue resulted in app crash with no error msg for me in Flutter. It would take one person half a day to update the docs/SDKs to save thousands of collective hours of wasted time...

JasonBennett41 avatar Aug 29 '24 21:08 JasonBennett41