Member-only story

How to deal with “Don’t call Firebase functions before CheckDependencies has finished” in Unity project

Krzysztof Turek
5 min readJan 8, 2021

--

Recently I was reading some reported issues on the Firebase Github account. There was one guy who didn’t know how to send an early event such as “loading_start” using FirebaseAnalytics.

The problem is that before you can use any Firebase tool, you should call the CheckAndFixDependenciesAsync() method. Otherwise, you receive the error “Don’t call Firebase functions before CheckDependencies has finished”. The method is asynchronous so Firebase might not be ready when you want to send a “loading_start” event and you have to drop it. But, of course, you can handle it in a smart way. I will show you how we do that at CC Games.

A good rule of thumb is not using third-party libraries directly. I always recommend creating a wrapper as an additional layer of an abstraction. Thanks to this, you avoid binding all your components to third-party code. Following the single responsibility principle, we separate code responsible for checking dependencies from the rest. Last but not least, to get rid of callbacks hell, we use TAP — Task-based Asynchronous Pattern. Actually, we use the UniTask library, which is a more efficient way of using TAP for Unity. It is also worth mentioning that our game architecture is based on ScriptableObjects, so don’t be scared of…

--

--

Krzysztof Turek
Krzysztof Turek

No responses yet