Update (June 23, 2014): This post is about GeoFire 1.0. We have since released GeoFire 2.0 which can be read about in a blog post here.
Location based services are hot. From a black car to the best sushi near you, your favorite apps use location tracking and localized search to bring the (relevant) world to your fingertips. Today we’re excited to release GeoFire - a geospatial library for Firebase that makes it easy for you to add real-time, location-based features to your app; with just a few GeoFire function calls, you can leverage your users’ locations too.
The What
Imagine you want to build an app to monitor airplanes in and around the San Francisco airport - the app finds planes entering and leaving the airport’s airspace, which is defined by a preset radius around the control tower, and keeps track of all planes that are within the airspace.
The app needs two location-based features:
Localized search, to find planes that are located within the preset radius from the tower. As planes enter and leave the airspace, the search results must change too. Real-time location tracking, to ensure plane locations in the app are up-to-date.
Implementing these features using just Firebase is non-trivial: you have to store the planes’ locations, represented as latitude-longitude pairs, implement distance calculation with latitude-longitude pairs, implement efficient location modification and re-calculation of distances, …and ten other things you’d rather not; so we built GeoFire for you.
The How
The GeoFire library provides functions to store data that you’d like to query by location, update location data, and perform location based searches that reflect location updates in real-time.
With Firebase and GeoFire, all you need to do to build the control tower app is:
Call GeoFire’s insertByLocWithId function to store the planes’ initial locations to Firebase. Call the updateLocForId function to update the planes’ locations as they move. Call the onPointsNearLoc function with the tower’s location and airspace radius to get the set of planes within the airspace. Any changes to the set are automatically reported in real-time, so the function need only be called once.
insertByLocWithId
updateLocForId
onPointsNearLoc
And that’s it, you’re done. Yup, that’s what we said - location-based anything is easy with GeoFire.
The But Really How
To store data by location in Firebase, GeoFire converts the latitude-longitude pair to a geohash. A geohash is an alphanumeric string which is generated by interleaving the bit representations of the latitude and the longitude coordinates of a location, and base32-encoding the result. Geohashes have a neat property that makes them suitable for geospatial queries like localized search: points with similar geohashes are guaranteed to be near each other. (It's worth noting that points that are near each other may not have similar geohashes though.)
The data for location querying is stored at its geohash in Firebase. To search for the nearest data points to a given location, GeoFire executes a series of a prefix queries over the geohashes; the set of prefixes queried depends on the search radius and the zoom resolution. This blog post provides a good introduction to the terminology and geohashing.
For location queries by client-provided id, GeoFire also inserts data at its id in Firebase. A simple double look-up or look-up+operation is all that’s needed to support the x-by-Id functions then.
The Fun and Profit
GeoFire makes it delightfully easy for you to add location-based features to your app. So go forth, treat your users to some of that localized love we all love!
As always, we’re all ears for feedback, comments and questions - reach out to us via the Firebase google group or Twitter!
We first told the world about Firebase on April 12th, 2012.
We were blown away with the response: 35,000 unique visitors and 3,000 developer sign-ups in the first 24 hours.
The enthusiasm hasn’t waned over the past 16 months and this momentum has brought us to today’s big announcement. We’re taking the ‘beta’ label off and are officially launching Firebase!
This means two things: (1) Firebase is ready for large, mission-critical applications and (2) Firebase is now a paid product.
We operate at serious scale. Firebase is trusted by some of the biggest companies, and every day we see large, polished apps being launched on Firebase. Here are some highlights:
To ensure the long-term sustainability of Firebase, we’re now a paid product. We have a large free tier that is great for development and small production apps. Our paid tiers start at $49 / mo, and we have Enterprise pricing available for apps that need to scale to millions of concurrent users and terabytes of data. You can see our pricing here.
Thank you!
We want to thank you all for your help. Developer feedback is the reason the Firebase API is so concise and powerful. Your support requests, one-on-one feedback at hackathons, and honest critiques have helped us immensely. Please keep giving us your feedback.
Here are some of the highlights from our time in beta:
Our progress so far has been made with a small and talented team. Now that we’ve raised our Series A we’ll be expanding our team to better serve if you. If you’re an exceptional engineer, designer, or community manager you should join us!
The Future
We’re building the easiest-to-use platform for building rich, modern applications. We get up every morning because we’re passionate about helping developers create extraordinary experiences for their users, and we’re just getting started on this mission. You’ll see some great new features coming soon, including advanced querying, expanded platform support, offline disk persistence, and improved debugging and analytics tools.
Thank you again for your support. Keep building amazing things!
We’re happy to announce a new feature that gives you more power and flexibility when writing your Security and Firebase Rules! Specifically, we’re expanding the operations you can use for validating string data. You can now use .length, .contains(), .beginsWith(), .endsWith(), .replace(), .toLowerCase(), and .toUpperCase() to examine and manipulate strings. Here are a few examples of what you can do with the new operations:
.length
.contains()
.beginsWith()
.endsWith()
.replace()
.toLowerCase()
.toUpperCase()
Ensure only a string of at least 10 characters can be written:
".validate": "newData.isString() && newData.val().length >= 10"
Allow read access only if auth.identifier ends in @company.com:
".read": "auth.identifier.endsWith('@company.com')”
Normalize an email address and check for its existence under /users/:
".read": "root.child('users').child(auth.email.replace('.', ',').toLowerCase()).exists()"
For full details and more examples, see the documentation. And let us know what you’d like to see next!
Today, we are happy to announce Firechat: multi-featured open source chat powered by Firebase. Firechat is simple and easily extensible, and is intended to give our developers a big head start when building chat products on Firebase.
Chat is one of the most fundamental use-cases for Firebase, and we know that designing and building full-featured chat from the ground-up can be time consuming. With Firechat, you get robust, secure chat that works out of the box, and a concise, documented foundation upon which you can customize and extend to meet your specific needs.
Out of the box, Firechat will work seamlessly with your existing authentication, or with Firebase Simple Login. Users can chat with other users via any number of public rooms listed, or public and private chat rooms they create. Users can also view the list of users active in any room, or across any room on the site, search them by name, mute users, or invite them to a chat room.
Since it’s built on Firebase, Firechat is built using only client-side code. Additionally, it is fully secure, relying upon Firebase’s authentication and declarative Security and Firebase Rules to ensure that only the right users can read or write data when you want them to.
Ready to learn more? Check out a live demo, complete with documentation, integration information, and annotated source code at firebase.github.io/firechat.
When you’re ready to start building, star / fork the repo on GitHub, and let us know what you build! We’d love to hear your feedback, questions, and feature requests, so don’t hesitate to get in touch.
Today, we are excited to announce full support for Java and Android! Now, Android developers can easily add real-time features to their applications without worrying about networking, scaling, or writing complicated server code.
Three months ago we launched native Firebase support for iOS and OSX devices. This was our first step into the world of mobile and we were thrilled with the reception. Now, with the new Java / Android SDK, we natively support more than 90% of all smart phones in the world.
Now that Firebase is supported on the web and both major mobile platforms, it's a perfect fit for building cross-platform applications. Each platform creates and consumes the same data type (JSON), and changes written to Firebase on one platform will show up seamlessly on any other.
Firebase's synchronization-based API is especially powerful in mobile applications. The SDK transparently handles caching, reconnecting, and data merging. Apps built with Firebase will remain responsive even when a device is offline, and changes will be synced back to the Firebase servers when a network becomes available again.
Our Java SDK can be used from your backend as well to allow you to synchronize and modify data directly from your servers. This lets you perform additional data processing, trigger events when certain data changes occur, and even mirror your Firebase data in other kinds of data stores.
You can get started using the Firebase Java SDK by following the steps in the Java / Android Quickstart Guide. In addition, check out the sample applications available on GitHub: Chat and Shared Drawing.
We're excited to see the apps you build, and we can't wait for those "pull to refresh" buttons to become a thing of the past.
To get updates on new SDKs as well as new versions of existing SDKs, follow @FirebaseRelease.