firebase / firebase/firebase-ios-sdk

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

Open
#1,738 4 comments 5 reactions 0 assignees View on GitHub
api: functions type: feature request
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### 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](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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.