Skip to content

[FR] [ISSUE] Cloud Function does not support FIRTimestamps (Support FIRTimestamps / Support Dates again) #1738

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

Open
serjooo opened this issue Aug 23, 2018 · 4 comments

Comments

@serjooo
Copy link

serjooo commented Aug 23, 2018

Environment

  • Xcode version: 9.4.1 (9F2000)
  • Firebase SDK version: 5.6.0
  • Firebase Component: FirebaseFunctions (2.1.0), FirebaseFirestore (0.13.1)

The problem

As I was calling a Cloud Function I received a fatal error saying:

'FIRInvalidArgumentException', reason: 'Unsupported type: NSDate

At first I thought it was Firestore throwing the exception as Firestore always recommended to use FIRTimestamps as Date objects will no longer be supported and might break in future releases. With this initial thought, I went ahead and updated my Model objects to start using FIRTimestamps. You might wonder why I updated my model objects? I have made my Model objects Codable with the help of a pod called https://github.com/alickbass/CodableFirebase to make it convenient to directly using structs or classes with Firestore, it worked with CloudFunctions as well. After using FIRTimestamp I got the same exception with unsupported type FIRTimestamp.

'FIRInvalidArgumentException', reason: 'Unsupported type: FIRTimestamp for value FIRTimestamp: seconds=1535053882 nanoseconds=638557910>'

Right now I'm stuck between having to rewrite all my CloudFunction dictionaries manually or write a method that makes sure FIRTimestamps are passed as String Date values or as milliseconds. This makes it very inconvenient to have conflicting requirements with both Google products.

Edit:

Realized NSDate was never supported to begin with. I broke my project by adding a date to the object and requiring it. Nevertheless, this is still a problematic issue.

Steps to reproduce:

Pass a Date object or FIRTimestamp object in the dictionary to a CloudFunction

@serjooo serjooo changed the title [FR] [ISSUE] Cloud Function does not support FIRTimestamps (Supoort FIRTimestamps / Support Dates again) [FR] [ISSUE] Cloud Function does not support FIRTimestamps (Support FIRTimestamps / Support Dates again) Aug 24, 2018
@bklimt
Copy link
Contributor

bklimt commented Sep 7, 2018

Hi @serjooo. You are correct that NSDate/FIRTimestamp are not yet supported by Cloud Functions. Thank you for letting us know how this functionality would be useful to you. We are still considering how best to support this particular use case, and may add such functionality in the future.

@psyh
Copy link

psyh commented Jan 25, 2020

So FIRTimestamp - is useless. It causes more problems than benefits

@PomegranateApps
Copy link

I'm currently encountering this issue too. It would be great to see it fixed in the next release.

@sophiagatliff
Copy link

sophiagatliff commented Apr 12, 2021

Can provide a use case:

Use selects a date in the app. This fires a HTTPs.onCall for an API call to Google Calendar, with a min/max time set for that date, to get all events for that date. Would be nice to be able to upload the Date/Timestamp directly from the client.

Workaround right now is to upload a string for the selected day, and then create the date in javascript from the string reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants