API Development

Module Development Guide Reference Module for iOS and Android

Last month at the CODESTRONG conference, we announced the availability of the iOS version of the Module Development Guide reference module. We are happy to announce that the Android version of the reference module is now available. You can find the source code files for both at the titanium_modules Github repository.


Modules are your path to extending the core Titanium platform with additional functionality. You can easily add custom code or access 3rd-party libraries with a module. Modules are written in native code (i.e. Objective-C on iOS and Java on Android) and provide the bridge between your JavaScript and the native code.

Getting Started

The Module Development Guide tutorials are an excellent starting point for developing your modules. However, it can be extremely helpful to have working code that demonstrates the principles and concepts in module development. That is the main purpose of this reference module. The module demonstrates core functionality that you will need in developing your module:

  • Life Cycle Events – module loading, proxy loading, view proxy loading
  • Properties – Types, getters, setters, property change notifications
  • Methods – Method signatures and annotations
  • Method Parameters – Type validation, type conversion, pass-by-value / reference
  • Callbacks and Events – Event registration, asynchronous notifications, synchronous callbacks
  • Miscellaneous – Accessing module and application assets, defining constants

Take a look at the module source code to understand how to implement each of these features. Feel free to cut-and-paste the code directly from the reference module source into your own module source code, removing any extra or unused parts of the code as necessary.

Example Application

Along with the module source code you will find a full working example application that exercises all of the functionality of the module. Both the iOS and the Android version of the application use the exact same JavaScript code. While it is not always possible, this demonstrates that you can have API parity across platforms with your module.

The sample application demonstrates the following aspects from the reference module:

  • Proxy Loading – demonstrates the lifecycle events that occur when a proxy is loaded and unloaded
  • View Proxy Loading – demonstrates the lifecycle events that occur when a view proxy is loaded and unloaded, along with the lifecycle events for the corresponding view object
  • Properties – demonstrates how to access proxy properties and receive notifications when properties are updated
  • Methods – demonstrates a number of ways to call proxy methods and pass various types of parameters
  • Parameters – demonstrates how different types of parameters are received by the native module
  • Callbacks & Events – demonstrates how to call back into and fire events to JavaScript from the native module
  • Assets – demonstrates how to locate and access module-specific and application resources from within the native module
  • Constants – demonstrates how to declare constants in the native module and reference them in the JavaScript code
To run the iOS version of the application simply execute the ‘titanium run’ command from the iOS project folder. To run the Android version you will first need to copy the ‘build.properties.example’ file to ‘build.properties’ and then edit the ‘build.properties’ file to set the path information for your system. Then execute the ‘ant run’ command from the Android project folder. Note that you will need version 1.7.3 of the Titanium SDK installed.

CODESTRONG Presentation

The CODESTRONG presentation on module development and the introduction of the module development guide reference module can be viewed here.

The slides from the presentation can be viewed here.

Module Development Resources: