Hey folks,
I want to use Firestore and Cloud Storage from my KMM app.
What is the best approach nowadays.
I have seen https://github.com/gitliveapp/firebase-kotlin-sdk/ ( that seem to wrap native Firebase libraries ).
It is missing Cloud Storage support but from the look of other implementations, it seems like a not that big effort.
My question, isn't it better to use REST API directly from shared code?
t
Tiago Nunes
09/16/2021, 5:37 PM
Hi! We are using this library at our company for Firestore (and we’ve implemented the bits we needed for Storage in our fork), and I can recommend it.
The official firestore libraries use gRPC instead of REST, because this enables “bidirectional streaming” (used for live updates).
I don’t think making network calls with gRPC from shared code is possible/viable at the moment (https://github.com/grpc/grpc-kotlin/issues/51) — please someone correct me if I’m wrong.
The Firestore SDKs offer a great abstraction, and are really easy (and fun) to use.
So, I definitely think that if you’re going to use Firebase with KMM, this library is probably the right approach!
They accept pull requests and publish new versions often.
Hope this helps :)
🙏 1
m
Martin Rajniak
09/16/2021, 5:44 PM
Thank you - definitely helpful.
Forgot about the sync option of Firestore.
Any chance you plan to share the fork for Cloud Storage? :)
I will try to have a look at making a PR for it myself.
t
Tiago Nunes
09/16/2021, 5:59 PM
https://github.com/tiagonuneslx/firebase-kotlin-sdk
We use the storage branch to implement anything (and only what) we need -- it's a mess. So I wouldn't recommend using (or forking) it.
Take a look at putFile and getFile implementations, real simple stuff!
🙏 1
Tiago Nunes
09/16/2021, 6:15 PM
You can copy the code and contribute to their project in your own fork, if you want. I'm not planning on submiting a PR for storage any time soon...