Lew
Lew

Reputation: 1461

Firebase with mobile apps

Is FireBase only for use on desktop browsers, or can it be used with mobile apps as well? I have a feeling it can't be used with mobile (yet).

Though Android, for example, uses the WebKit engine (and its WebView component displays HTML pages without needing a full browser, and HTML pages can be loaded into a WebView either directly through a URL or injected as a string), Android WebKit doesn't yet (to my knowledge) support WebSockets, so if FireBase uses WebSockets (and I think I read somewhere that it does), then this precludes mobile apps (at least Android - don't know about iOS).

Any other way to achieve real-time apps on mobile with FireBase? Thanks!

Upvotes: 7

Views: 2307

Answers (1)

Kato
Kato

Reputation: 40582

Firebase supports all major mobile web browsers and even works in offline mode. There is even a node.js client and REST API.

It uses the standard fallback choices when WebSockets aren't available. Check out these questions from the FAQ:

What browsers and network connections does Firebase support? The Firebase JavaScript client supports all mainstream browsers (IE 7+, Firefox, Chrome, Safari, Opera, and major mobile web browsers), and it works on any network connection. Our team has spent years building this type of software and we have put a great deal of research and effort into ensuring we can communicate in a variety of environments. We even work through proxies and on various mobile providers where other real-time technologies may fail.

What happens to my app if I lose my network connection? Firebase transparently reconnects to the Firebase servers as soon as you regain connectivity. In the meantime, all Firebase operations done locally by your app will immediately fire events, regardless of network state, so your app will continue functioning correctly. Once connectivity is reestablished, you’ll receive the appropriate set of events so that your client “catches up” with the current server state, without you having to write any custom code.

Wait, does that mean my app will automatically work in “offline mode” and recover when it comes back online? Yes, yes, it does. :-)

UPDATE Ah, here we go. I wandered about looking for the SO question where the FB team answered this directly, and my search was not in vain:

The Firebase Javascript Client maintains a real-time bidirectional connection to the server. Under the covers, this uses WebSockets whenever possible (which have no limitations with regard to cross-origin connections) and falls back to hidden-iframe-based jsonp long-polling on older browsers (which sidesteps cross-origin issues by only doing requests).

Upvotes: 12

Related Questions