1

I'm getting the following error for all my Cloud Functions that are invoked by Firestore Background Triggers.

I'm not sure why the errors pop up. The client side is Swift (iOS) and I'm using ISO8601 Strings as Dates (not Date Objects).

As per this previous Question: Firebase Cloud Functions - Change Firestore settings

@Doug Stevensen says that:

you should use Timestamp objects when reading dates out of snapshots. If you're doing that, you can ignore this warning message.

What does he mean by reading dates out of snapshots? When I read any dates, I use my client side created ISO 8601 strings (that are stored as part of my Document Data). I don't ever use/reference context.timestamp so should I be able to ignore these warnings?

Is there any way to silence this warning so it doesn't show up every time a Cloud Function is run? Or can I ignore the warnings?

The behavior for Date objects stored in Firestore is going to change
    AND YOUR APP MAY BREAK.
    To hide this warning and ensure your app does not break, you need to add the
    following code to your app before calling any other Cloud Firestore methods:

  const firestore = new Firestore();
  const settings = {/* your settings... */ timestampsInSnapshots: true};
  firestore.settings(settings);

With this change, timestamps stored in Cloud Firestore will be read back as
Firebase Timestamp objects instead of as system Date objects. So you will also
need to update code expecting a Date to instead expect a Timestamp. For example:

  // Old:
  const date = snapshot.get('created_at');
  // New:
  const timestamp = snapshot.get('created_at');
  const date = timestamp.toDate();

Please audit all existing usages of Date when you enable the new behavior. In a
future release, the behavior will change to the new behavior, so if you do not
follow these steps, YOUR APP MAY BREAK.
siefix
  • 916
  • 1
  • 10
  • 19

0 Answers0