--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/4cbaae9d-2f3a-42ad-b186-298db92aae62%40googlegroups.com.
Hi Kato,
We wanted to use a cloud function to take a dictionary from an iOS/Swift client and do some work.
That dictionary included values of type String, Int, Bool, Array, Dictionary, and Date. These were common types that we use with the Firestore APIs the app also uses.
Using the functions.httpsCallable().call(data:, completion:) API, it was throwing due to the Date type not being supported in the data parameter. Reviewing the header files, I saw Date is not a supported type in the request.
I understand the underlying issue is probably tied to date type support (or lack of) in JSON. Not sure really as I am not aware of the layers between iOS and the callable cloud function I built and deployed.
When working with Firestore, Date from iOS gets converted into Timestamp which is great. I can then use the Firebase Console to inspect dates, make edits, and build pubsub.schedule and firestore.onUpdate cloud functions using Timestamp types directly. I do use the Admin SDK in my cloud functions as you mentioned.
When I started my https.onCall cloud function I just assumed I would get Timestamp in the request data, with help of some layer that sat in between, just like Firestore APIs. The assumption was my fault. The online docs (which are good) did not point out Timestamp was not supported very explicitly for callables, but the header files in the iOS SDK did confirm later the limits of data types for onCall request data.
What is interesting is that my onCall cloud function does convert Timestamp types in the response into a dictionary with _seconds and _nanoseconds keys and integer values.
{
“key” : {
“_seconds”: number,
“_nanoseconds”: number
}
}
So, my work around was this. On iOS, I encode Date types into the same format the cloud function was responding with:
This dictionary of number types replaced the Date type used when calling the cloud function on iOS and all was good again.
I then updated my cloud function to convert these encoded Timestamps dictionaries into actual Timestamp types…which I could then use natively in my cloud function…which did timestamp math and created various Firestore documents that stored Timestamp info along with other stuff.
Ideally, It would be great if the Firebase APIs for callable cloud functions handled Date (or Timestamp), similar to how Dates are handled when using Firestore or other cloud function APIs. The goal being to have consistency when opting to use a callable cloud function. As it is, I have to have special encoding in my Model layers on iOS that takes one path to encode Date data to call Firestore APIs which accept Date/Timestamp and then a different path for forming request data for a callable cloud function with won’t accept Date/Timestamp directly.
I hope this helped clarify things. For now, I’m up and going so please consider this as a feature request.
Regards,
Bill
Hi Bill,What exactly are you looking for here? The Admin SDK (used to interface with Firestore in Cloud Functions) has several methods for dealing with dates under Timestamp.☼, Kato
On Mon, Aug 26, 2019 at 6:32 PM 'Bill Moss' via Firebase Google Group <fireba...@googlegroups.com> wrote:
Hi,--Firestore APIs work nice to encode Date types on iOS and Swift when working with documents.Cloud functions are great but the lack of Date type encoding makes them difficult to consider using. I was surprised this was not supported. The online docs could have been better here.I'll put in a vote to have the iOS SDKs for firestore and cloud functions handle type encoding consistently.Is there any timeline for when Date type encoding will be included for calling firebase cloud functions?Is encoding Dates into strings in my iOS app the preferred workaround?Thanks,Bill
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/4cbaae9d-2f3a-42ad-b186-298db92aae62%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/422db177-7edf-45ad-a13b-e9d0f91842fe%40googlegroups.com.