Facebook released a completely rebuilt version of its iOS app for iPhone and iPad today, changing a fundamental aspect of the company's mobile strategy. Gone is the Web-centric, HTML5 approach. In its place, Facebook has rebuilt the iOS app using Apple’s native framework. The result? A more streamlined, faster app for the iPhone and iPad.
Ditching the Mobile Web
For earlier app versions, Facebook “wrapped” its mobile website (m.facebook.com) in code that allowed it to run on iOS and Android hardware. Items from Facebook’s newsfeed, friend’s lists and other features would be imported from the website and rendered using HTML5. Facebook would add iOS- or Android-native code that allowed the app to perform functions the mobile website could not, like accessing a smartphone’s camera. Then it would deploy this bundle on the various mobile platforms.
The advantages of this approach were several. Facebook could send updates to the app multiple times a day, so it could be very agile in addressing and fixing problems. Facebook could also support many different types of devices and platforms with one code base. The company supported more than 7,000 devices with this approach, reaching 500 million mobile users.
Facebook engineering manager Dave Fetterman described the approach at f8, Facebook’s developer conference, last year:
“Being able to write it once today and ship it tomorrow? That is something that Facebook is really good at and that we love doing, and that is at the center of being able to move fast. Move fast has an implicit third clause - move fast, break things, and fix things fast. That is very difficult to do if you have already shipped your binary to Apple or Android and they have to download another version of it.”
Facebook’s apps on some platforms, including Windows Phone, BlackBerry and Android (as well as the traditional mobile website), are still be built this way. According to The Verge, they may be getting the native treatment in the future. But the company decided to handle iOS differently.
“[W]e realized that when it comes to platforms like iOS, people expect a fast, reliable experience and our iOS app was falling short. Now that our mobile services had breadth, we wanted depth. So, we rewrote Facebook for iOS from the ground up (I really did open up Xcode and click "New Project") with a focus on quality and leveraging the advances that have been made in iOS development,” wrote Facebook developer J.P. Dann in a blog post explaining the changes.
Embracing Native, Building for Speed
Facebook achieved three main benefits by embracing native code for its iOS app. Foremost, the app now opens faster, without the lag that many users complained about. Second, scrolling is smoother. Third, photos are uploaded instantly.
Facebook is now using Objective-C for its iOS app, which executes much faster than HTML5. It built the app in Apple’s iOS development framework called XCode. The transition created some challenges for the Facebook team, such as pre-caching content on the newsfeed so it would load immediately upon opening the app.
A natural consequence of moving from HTML5 to Objective-C is better scrolling. Any developer who works extensively in HTML5 knows that smooth scrolling is not easily achieved. Essentially, Facebook did nothing special here to increase the scrolling outside of moving from one code base to another.
Facebook has released two other native applications to iOS: Messenger and Camera. The Messenger feature within the main Facebook app is the same code in the standalone Messenger app. In many ways, Dann explains, the Messenger app was the testing ground for the new Facebook app, helping the Facebook mobile team learn how to develop with native code and how users would respond to the app.
Why Rebuild for Native?
Facebook has been a firm believer in HTML5 and Web-based technology. The pillar of Facebook’s platform has always been the browser. Why change now?
The obvious reason is, as Dann explained, speed and efficiency. Facebook's iOS app is certainly better now. It is hard to begrudge a company for making a product better, even if it goes against the historic principles of that company.
Another reason, a conspiracy theory perhaps, is that Apple forced Facebook to rebuild its mobile app for iOS if it was going to get the deeply embedded treatment in the upcoming release of iOS 6 that Twitter got in iOS 5. One of the biggest threats of Apple’s dominance in mobile is the potential for an open Web-based market independent of Apple’s App Store. Facebook has been one of the biggest proponents of HTML5 and many developers follow the company’s lead in this area. By forcing Facebook to go native, Apple wins a philosophical victory in the war for the hearts and minds of mobile developers.