Building functional hybrid applications for the iPhone and Android Part 2 by Carlos Andreau
Kathleenholm 2700009BHX Visits (4411)
This is the second and last article in a series of posts based on a presentation I gave with Mike Thompson at OSCON 2012 this year. The presentation was titled "Building Functional Hyrbid Application for the iPhone and Android" and we talked about how easy it is to get started with mobile application with IBM Worklight and WebSphere's Application Server Liberty Profile for the backend REST service.
Many businesses want to play in the mobile space. They want to have their own application and leverage the fact that many of their customers and/or employees have smartphones. The obvious solution is to start developing a mobile application, but it's not that straightforward! There are various mobile ecosystems you must support if you want to maximize the amount of users benefiting from your mobile application.
Native Applications are those built with the resources provided by the owner of the mobile Operating System. For example: You must have programmers that know their way around Java, the Android Software Development Kit (SDK) and the Eclipse Integrated Development Environment (IDE) if you want to deploy your application to folks that own Android phones. Similarly you must have C# developers that use Microsoft Visual Studio and those that program in Objective-C and use Xcode if you want to support Windows Phones and iOS devices (iPhone, iPad and iPod Touch) respectively. Let's not forget RIM's Black Berry phones that are still quite relevant in the business world!
This can quickly turn into a very time consuming and costly venture for many businesses, even those with large amounts of resources and knowledgeable software engineers.
We currently support building applications for Android, iOS, Windows Phone and Black Berry. No need to port you code to yet another programming language every time a new player enters the mobile space with a new OS or you want to upgrade your application to fix a bug or add a new feature. With IBM Worklight most of your code is 'common' code and you decide what parts of the code as specific to a particular environment and we take care to build the appropriate binaries. In Java-land it's like having the following classes: Common, iPhone (extends Common), Android (extends Common), WindowPhone (extends Common) and Black Berry (extends Common) and Mobile Web (extends Common) -- yes, you can even build web applications re-using the same code!
"But wait, what if my application needs to access 'native' functionally, such as capturing images and getting data from the sensors that are built into the phone such as the accelerometer?" you may quickly ask. I would gladly answer that we have thought about that! IBM Worklight comes with Apache Cordova built in, it allows you do access many things that would be inaccessible to typical web applications such as, but not limited to: capturing images, audio and video, geolocation data, accelerometer output and native events like: the battery low, the phone has internet connectivity, volume up button pressed and many others. I highly suggest you take a look at the Application Programming Interface for Apache Cordova to learn about all the functionality you get out of the box with IBM Worklight.
I have just scratched the surface! Worklight provides support getting data from various back ends (REST, SOAP, SQL) via Worklight's Adapters, it comes packed with security features (Authentication, LTPA, Reverse Proxies, Data Encryption), ability to handle various themes and different screen resolutions via Worklight Skins and many others.
To get started watch this 10 minute video I made that shows how to setup IBM Worklight from scratch and build a simple 'Hello World' application. Make sure you pause frequently and try to follow along. Fair warning: It takes more that 10 minutes to download everything even with a fast connection! If you prefer to read instead of watch video tutorials, here's the developerWorks article that the video is based on.
IBM Worklight comes with a lot of slide decks that tackle very specific features. You may be interested in the environment setup slides if you run into issues setting everything up for the various environments. After you have everything setup, take a look at the following modules: Adapters, Common Controls, Skins, Apache Cordova, Offline Access, Encrypted Cache, Authentication, Push Notifications, Device Analytics and anything else that grabs your attention.
If you decide to use jQuery Mobile here's a developerWorks article to get you started. You may also try Dojo Mobile and Sencha Touch. All of those framework provide a lot of UI elements optimized for small phone screens out of the box.
Feel free to ask for help in the IBM Worklight forum.
Good luck with mobile development,
Carlos Andreu (IBM Worklight Software Engineer)
Follow Carlos: http