Skip to content
Titanium SDK
Version12.5.0

You are reading 12.5.0. See this page in 13.4.1.

Titanium

moduleAndroidiPhoneiPadmacOSsince 0.1

Extends Titanium.ModuleTitanium.Proxy

The top-level Titanium module.

The Titanium module provides the Titanium Mobile API, allowing developers to access native features of each target environment. Currently, the Android and iOSenvironments are supported.

Titanium Namespace

The complete Titanium API is accessible from the Titanium namespace but, for convenience and brevity, the alias Ti is also provided. As the Titanium namespace is functionally-identical to its Ti alias, it is always recommended to use Ti in your code.

For example, the following pairs of Titanium calls behave exactly the same.

Titanium.API.info('Hello Titanium!');
Ti.API.info('Hello Titanium!');

Titanium.Utils.sha256('Hello Titanium!');
Ti.Utils.sha256('Hello Titanium!');

Titanium.App.Properties.setString('hello_msg','Hello Titanium!');
Ti.App.Properties.setString('hello_msg','Hello Titanium!');

Titanium.Database.open('mydb');
Ti.Database.open('mydb');

Global APIs

Titanium includes a number of built-in JavaScript objects that are not part of the Titanium namespace, including String formatting, timers, and the CommonJS require function. See Global APIs for details.

Properties 7

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

buildDate

Stringread-only

Date of the Titanium build.

buildHash

Stringread-only

Git hash of the Titanium build.

userAgent

String

User-agent string used by Titanium.

version

Stringread-only

Version of Titanium that is executing.

Methods 5

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Creates a new buffer based on the params.

Create a buffer with 1K bytes

var buffer = Ti.createBuffer({ length: 1024 });

Create a buffer with string

Create a buffer with the string "hello world" encoded in UTF-8

var buffer = Ti.createBuffer({ value: "hello world" });

Create a buffer with encoded float

Create a buffer with the encoded value of the double-precision floating point number 1.234567 in Big Endian (network) byte order

var buffer = Ti.createBuffer({ value: 1.234567, type: Ti.Codec.TYPE_DOUBLE, byteOrder: Ti.Codec.BIG_ENDIAN });
Parameters
ParametersTypeDescription
paramsCreateBufferArgs

creation arguments

4 fields
byteOrder? Number

The byte order of this buffer.

length? Number

The length of the buffer.

type? String

The type of data encoding to use with value.

value? String | Number

An initial value which will be encoded and placed in the buffer. If value is a Number, type must also be set. (this is simply a convenient way of calling Titanium.Codec.encodeString or Titanium.Codec.encodeNumber and placing the encoded value in the returned buffer.)

Returns Titanium.Buffer

The new buffer.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.