Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(firestore): Timestamp values #474

Open
4 of 14 tasks
Paganiniana opened this issue Oct 23, 2023 · 12 comments · May be fixed by #557 or #677
Open
4 of 14 tasks

bug(firestore): Timestamp values #474

Paganiniana opened this issue Oct 23, 2023 · 12 comments · May be fixed by #557 or #677
Labels
bug/fix Something isn't working package: firestore platform: ios iOS platform

Comments

@Paganiniana
Copy link

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Messaging
  • Performance
  • Remote Config

Did you test the latest version?

  • I use the latest version

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

If I read a document using the FirebaseFirestore.getDocument method, its snapshot.data object is completely missing any value that resolves as a Firestore Timestamp value. For example, a document of the following format in Firebase ...

const docData = {
     author: "Some Name",
     description: "Some description",
     creationDate: <some timestamp>,
}

... is returned as ...

const docData = {
     author: "Some Name",
     description: "Some description",
}

Expected behavior

I would expect that any snapshot.data value has certain values in Firestore, it this method would return those values as part of its resolved object structure.

Reproduction

https://github.com/Paganiniana/capawesome-bug-reproduction

Steps to reproduce

(See the readme)

  1. build project
  2. run on local web server
  3. run on an iOS device
  4. observe difference in console logs

Other information

No response

Capacitor doctor

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 5.5.0
@capacitor/core: 5.5.0
@capacitor/android: 5.5.0
@capacitor/ios: 5.5.0

Installed Dependencies:

@capacitor/android: not installed
@capacitor/cli: 5.5.0
@capacitor/ios: 5.5.0
@capacitor/core: 5.5.0

[success] iOS looking great! 👌

Before submitting

  • I understand that incomplete issues (e.g. without reproduction) are closed.
@Paganiniana Paganiniana added bug/fix Something isn't working needs: triage labels Oct 23, 2023
@Paganiniana
Copy link
Author

In poking around the codebase, I've narrowed down the problem to the FirebaseFirestoreHelper.swift file. It seems the createJSValue method returns nil for instances of Timestamp. I'm manually marking its type and passing up its value as a second/nano second pair. In the JS layer, I'm passing these to the timestamp constructor, making it work just like the web client. If we could make these changes in firestore/src/index.ts and wrap the necessary read/write methods to pass this information back and forth from the native/web layers, that would be great!

Screenshot 2023-10-23 at 4 03 50 PM

@robingenz
Copy link
Member

Thank you for reporting this issue! Would you be willing to create a PR with your idea? I would then take a closer look.

@Paganiniana
Copy link
Author

Sure thing, @robingenz . I'll see if I can get that together, this morning.

@Paganiniana Paganiniana mentioned this issue Oct 24, 2023
@robingenz robingenz added this to the v5.3.0 milestone Oct 24, 2023
@robingenz robingenz modified the milestones: v5.3.0, v5.4.0 Nov 28, 2023
@robingenz robingenz changed the title bug: Timestamp values bug(firestore): Timestamp values Dec 14, 2023
@robingenz robingenz modified the milestones: v5.4.0, v5.5.0 Jan 23, 2024
@robingenz robingenz modified the milestones: v5.5.0, v6.0.0 Feb 14, 2024
@SureshKumarToverto
Copy link

@robingenz Could you please provide any updates on this matter or offer an estimated timeframe for resolving the issue? Thank you.

  1. How to save date in Angular as a timestamp to Firestore #564
  2. Issue #474 #475

@robingenz
Copy link
Member

@SureshKumarToverto As already mentioned in #564 (comment), this is currently a bug in Capacitor (see ionic-team/capacitor#7252). I have to wait until it's fixed.

@johnmckay-reward
Copy link

@robingenz does this same bug also affect geopoints? we store both timestamps and geopoints in our firestore db, everything comes back fine when testing in the browser, but when we compile into a native iOS app and test on the device, neither timestamps/geopoints come back

@robingenz
Copy link
Member

@johnmckay-reward No, this should be another issue. Please create a separate bug report.

@robingenz robingenz removed this from the v6.0.0 milestone Apr 16, 2024
@mdean808
Copy link

Is there a workaround for this bug while waiting for the capacitor team to fix ionic-team/capacitor#7252, or should I switch to storing my dates as strings as opposed to the Timestamp type in firestore to avoid this issue?

@robingenz
Copy link
Member

No, there is currently no workaround. I have another idea on how to solve this, but of course I would prefer the problem to be solved in the Capacitor Core. I currently save all timestamps as ISO 8601 strings.

@mamillastre mamillastre linked a pull request Jul 17, 2024 that will close this issue
3 tasks
@u12206050
Copy link

Any update, this is pretty crucial I would think to any app using firestore?

@robingenz
Copy link
Member

No, there are no updates yet. It's still on my to-do list for this year. For the time being, I recommend saving all timestamps as ISO 8601 strings.

@gdrose
Copy link

gdrose commented Dec 23, 2024

I'm still facing the same issue (on iOS). Are there any updates regarding this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/fix Something isn't working package: firestore platform: ios iOS platform
Projects
None yet
7 participants