I am attempting to use the firebase database in my watchKit app. I have developed this feature on my iPhone application but have found it difficult to do the same on my Watch app. When I attempted to import firebase into the VC class in watch app, it is creating an error no such module 'firebase'
.
Is it possible to use firebase inside a watch app?
Sadly there is no Firebase
support for watchOS2
and watchOS3
due to the fact that there's no support for CFNetwork
in these versions of watchOS
and Firebase
is highly dependent on this framework. Source (thanks for the link @FrankvanPuffelen in comments).
You have two alternatives:
Firebase REST API
directly from your watch app.Firebase
communication from the iPhone
app and use the WatchConnectivity
framework to send the relevant changes to your watch app.Depending on your exact use case, you could choose any of the two. The main advantages/disadvantages of these two are that the WatchConnectivity
framework is quite limited as in when it can be used. Both of your apps needs to be running at least in the background for the WatchConenctivity
framework to work. On the other hand, if you choose to use the REST API
, you don't need the watch app to communicate with the iPhone
counterpart, the watch app can directly get the Firebase
data using network requests. However, in this scenario, the network usage will be bigger, since you will need to essentially fetch the same information both for the iPhone
and watch apps.
Update for watchOS 6: Firebase Messaging has been released with watchOS support, however, the Realtime Database along with other Firebase SDKs are still not supported. You can track the progress of them in this GitHub issue, which also contains links to the specific feature request issues for the other SDKs.