News

Published on December 20th, 2012 | by Successblogger

0

Writing Cross-platform Apps with Appcelerator Titanium

Web developers, you no longer need fear Objective-C. Appcelerator Titanium makes it super easy to code applications for virtually all platforms using one single language – JavaScript – and a big old API.

Among the platforms supported are iOS and Android. There are specific APIs for Android tablets – we’ll look closer at this below.

The first thing you will need to get Appcelerator up and running is the Titanium Studio itself, available from the Appcelerator website. While you’re there, make sure to bookmark the documentation, as it’s invaluable in learning how to make the best of the program later. Finally, before we moving on to installation head over to stackflow.com and bookmark their forums. You’ll constantly find yourself dipping into these for guidance, advice and code snippets to save you time.

Since Appcelerator is designed to help you code cross-platform apps, you’ll need the various SDK (Source Development Kits) for each of the platforms you intend to target. Without further ado, here’s the rundown on how to do that:

iOS. For iOS, you’ll need a developer license and the latest version of Xcode. A developer license costs around a hundred dollars for the year, and allows you to publish unlimited apps to the app store. Xcode will include all the previous iterations of the iOS SDK. Once you’ve got hold of these tools, check the ‘getting started’ section in Titanium Studio documentation to learn how to extract a Developer Provisioning Profile and Development Certificate for use within the program.

Android. For Android, there’s no pricey developer license. You do, however, need a copy of the Oracle JDK – which is free (you can Google for it), and the Android SDK Manager, which is available from the Android website. Again, once you have these things, check the ‘getting started’ section in the Appcelerator documentation to learn which bits you will need to extract, or alter and how.

BlackBerry. To support RIM’s ecosystem, you need to be an Appcelerator Pro or Enterprise subscriber. If you are, head over to the Titanium Studio documentation to find out how to get started coding for BlackBerry.

Once you’re up and ready, you’ll be coding with JavaScript. This is a flexible, object-oriented (OO) language. Many of the methods (functions) you’ll be using are included as part of the Appcelerator API, but standard JavaScript functions work too. Those included in Appcelerator convert your JavaScript to the native language of the device in question, which means that you can take full advantage of native device features. For example, in Android tablets you can set the color of any LED on the device. The code is Titanium.Android.Notification.setLedARGB(number ledARGB). As you can see, you access the device-specific JavaScript functions (which are themselves substitute for native code) by calling up the Titanium selector first, and then drilling down to specifics. Many functions, though, like Titanium.App.setEventListener(event, callback) are cross-platform.


About the Author



Back to Top ↑