Titanium.Platform
> Titanium.Platform

The top-level Platform module. The Platform module is used to access the device's platform-related functionality.

Examples

Battery Event Example

Obtaining battery data when the battery state changes.

Titanium.Platform.addEventListener('battery', function(e){
  Ti.API.info('The battery state has changed to ' + e.state);
  Ti.API.info('The battery level is ' + e.level);
  Ti.API.info('The battery event source is ' + e.source);
  Ti.API.info('The battery event name ' + e.type);
});
  • 0.8
  • 0.8
  • 0.8
Defined By

Properties

Titanium.Platform
BATTERY_STATE_CHARGING : Numberreadonly

Constant to indicate that the system is plugged in and currently being charged.

Constant to indicate that the system is plugged in and currently being charged.

Titanium.Platform
BATTERY_STATE_FULL : Numberreadonly

Constant to indicate that the battery is fully charged.

Constant to indicate that the battery is fully charged.

Titanium.Platform
BATTERY_STATE_UNKNOWN : Numberreadonly

Constant to indicate that the battery state is not known or monitoring is disabled.

Constant to indicate that the battery state is not known or monitoring is disabled.

Titanium.Platform
BATTERY_STATE_UNPLUGGED : Numberreadonly

Constant to indicate that the system is unplugged.

Constant to indicate that the system is unplugged.

Titanium.Platform
: Stringreadonly
System's WIFI IP address. ...

System's WIFI IP address. No other network types are supported.

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2.0
  • 3.2.0
  • 3.2.0
Titanium.Platform
architecture : Stringreadonly

System's processor architecture.

System's processor architecture.

Titanium.Platform
availableMemory : Numberreadonly

System's unused memory, measured in megabytes on iOS and bytes on Android.

System's unused memory, measured in megabytes on iOS and bytes on Android.

Titanium.Platform
: Numberreadonly
Battery level in percent, accessible only when batteryMonitoring is enabled. ...

Battery level in percent, accessible only when batteryMonitoring is enabled. Measured in 5% increments on iPhone/iPad.

Titanium.Platform
: Boolean
Determines whether battery monitoring is enabled. ...

Determines whether battery monitoring is enabled.

Default: false

Titanium.Platform
: Numberreadonly
Indicates the state of the battery. ...

Indicates the state of the battery. Accessible only when batteryMonitoring is enabled.

This API can be assigned the following constants:

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

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

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true

  • 3.0.0
  • 3.0.0
  • 3.0.0
Titanium.Platform
displayCaps : Titanium.Platform.DisplayCapsreadonly

Returns the DisplayCaps object.

Returns the DisplayCaps object.

Note that the displayCaps property begins with a lowercase letter, which differentiates it from the DisplayCaps object that it returns.

Titanium.Platform
id : Stringreadonly

Applications's globally-unique ID (UUID).

Applications's globally-unique ID (UUID).

On Android, this may be the UDID (unique device ID). For iOS, this is a unique identifier for this install of the application.

Previously on iOS this may have been a UDID, but access to this has been restricted by Apple. For more information, see Apple's uniqueIdentifier documentation.

To use a UUID across different applications of the same vendor, use identifierForVendor instead.

To use a UUID for tracking / advertising purposes, use identifierForAdvertising instead.

Titanium.Platform
identifierForAdvertising : String

An alphanumeric string unique to each device, used only for serving advertisements.

An alphanumeric string unique to each device, used only for serving advertisements.

Unlike the identifierForVendor property, the same value is returned to all vendors. This identifier may change, for example, if the user erases the device, so you should not cache it.

In iOS 10.0 and later, the value of this property is all zeroes when the user has limited ad tracking.

If the value is null, wait and get the value again later. This happens, for example, after the device has been restarted but before the user has unlocked the device.

  • 7.0.0
  • 7.0.0
Titanium.Platform
identifierForVendor : Stringreadonly

An alphanumeric string that uniquely identifies a device to the app's vendor.

An alphanumeric string that uniquely identifies a device to the app's vendor.

The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor. See the Apple docs for more infos.

  • 7.0.0
  • 7.0.0
Titanium.Platform
isAdvertisingTrackingEnabled : Booleanreadonly

A Boolean value that indicates whether the user has limited ad tracking.

A Boolean value that indicates whether the user has limited ad tracking.

Check the value of this property before performing any advertising tracking. If the value is false, use the advertising identifier only for the following purposes: frequency capping, attribution, conversion events, estimating the number of unique users, advertising fraud detection, and debugging.

  • 7.0.0
  • 7.0.0

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.

  • 3.6.0
Titanium.Platform
locale : Stringreadonly

System's default language.

System's default language.

Locale, as a combination of ISO 2-letter language and country codes. For example, en-US or en-GB. See the ISO 639-1 and ISO 3166-1 alpha-2 sections of wikipedia for reference.

Titanium.Platform
macaddress : Stringreadonly

System's network interface mac address, or app UUID.

System's network interface mac address, or app UUID.

On iOS, this value is the app's UUID. Apple does not allow access to any hardware identifier information as it can be used for unique device identification, which they have prohibited.

Titanium.Platform
manufacturer : Stringreadonly

Manufacturer of the device.

Manufacturer of the device.

Returns the manufacturer of the device, for example, motorola. Virtual devices return unknown.

  • 3.0.0
  • 3.0.0
  • 3.0.0
Titanium.Platform
model : Stringreadonly

Model of the device.

Model of the device.

An identifier of the hardware model of the device. For example, HTC Sensation Z710e.

Virtual devices will also return a value. For example, sdk for the standard Android SDK and google_sdk for the enhanced Android Google APIs SDK running in an emulator, and Simulator for iOS running in a simulator.

Examples

Testing for a Virtual Device

Determine whether the application is running on a virtual device.
    if (Ti.Platform.model === 'Simulator' || Ti.Platform.model.indexOf('sdk') !== -1 ){
      alert('Accelerometer does not work on a virtual device');
    } else {
      // Add Accelerometer event listener
    }
Titanium.Platform
: Stringreadonly
Name of the platform. ...

Name of the platform. Returns android for the Android platform, iPhone OS for the iOS platform (iPhone, iPad, or iPod Touch), and windows for the Windows platform.

Since iOS 10 this property returns iOS for for the iOS platform (iPhone, iPad, or iPod Touch).

Titanium.Platform
: Stringreadonly
System's WIFI network mask. ...

System's WIFI network mask. No other network types are supported.

Titanium.Platform
: Stringreadonly
Short name of the system's Operating System. ...

Short name of the system's Operating System. Returns android for the Android platfrom, iphone for the iPhone or iPod Touch, ipad for the iPad, windowsphone for Windows Phone, and windowsstore for Windows Store platform.

Titanium.Platform
: Stringreadonly
Operating System architecture. ...

Operating System architecture. On Android, this is 32bit.

Titanium.Platform
processorCount : Numberreadonly

Number of processing cores.

Number of processing cores.

Titanium.Platform
runtime : Stringreadonly

Short name of the JavaScript runtime in use.

Short name of the JavaScript runtime in use.

On iOS this is "javascriptcore", on Android either "v8" or "rhino".

Titanium.Platform
: Stringreadonly
System name, if set. ...

System name, if set. On iOS, this can be found in Settings > General > About > Name.

Titanium.Platform
version : Stringreadonly

System's OS version.

System's OS version.

Defined By

Methods

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

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

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to invoke when the event is fired.

Returns

  • void
Applies the properties to the proxy. ...

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • props : Dictionary

    A dictionary of properties to apply.

Returns

  • void
Titanium.Platform
( url ) : Boolean
Returns whether the system is configured with a default application to handle the URL's protocol. ...

Returns whether the system is configured with a default application to handle the URL's protocol.

On iOS, this method might return false if you have not whitelisted the URL schemes you query in your tiapp.xml.

  • 0.8
  • 0.8

Parameters

  • url : String

    The url to check.

Returns

  • Boolean
Titanium.Platform
( ) : String
Creates a globally-unique identifier. ...

Creates a globally-unique identifier.

Returns

  • String
Fires a synthesized event to any registered listeners. ...

Fires a synthesized event to any registered listeners.

Parameters

  • name : String

    Name of the event.

  • event : Dictionary

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

Returns

  • void
Titanium.Platform
( ) : String
Gets the value of the address property. ...

Gets the value of the address property.

Returns

  • String
Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the architecture property. ...

Gets the value of the architecture property.

Returns

  • String
Titanium.Platform
( ) : Number
Gets the value of the availableMemory property. ...

Gets the value of the availableMemory property.

Returns

  • Number
Titanium.Platform
( ) : Number
Gets the value of the batteryLevel property. ...

Gets the value of the batteryLevel property.

Returns

  • Number
Titanium.Platform
( ) : Boolean
Gets the value of the batteryMonitoring property. ...

Gets the value of the batteryMonitoring property.

Returns

  • Boolean
Titanium.Platform
( ) : Number
Gets the value of the batteryState property. ...

Gets the value of the batteryState property.

Returns

  • Number
Gets the value of the bubbleParent property. ...

Gets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Returns

  • Boolean
Gets the value of the displayCaps property. ...

Gets the value of the displayCaps property.

Returns

Titanium.Platform
( ) : String
Gets the value of the id property. ...

Gets the value of the id property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the identifierForAdvertising property. ...

Gets the value of the identifierForAdvertising property.

  • 7.0.0
  • 7.0.0

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the identifierForVendor property. ...

Gets the value of the identifierForVendor property.

  • 7.0.0
  • 7.0.0

Returns

  • String
Titanium.Platform
( ) : Boolean
Gets the value of the isAdvertisingTrackingEnabled property. ...

Gets the value of the isAdvertisingTrackingEnabled property.

  • 7.0.0
  • 7.0.0

Returns

  • Boolean
Gets the value of the lifecycleContainer property. ...

Gets the value of the lifecycleContainer property.

  • 3.6.0

Returns

Titanium.Platform
( ) : String
Gets the value of the locale property. ...

Gets the value of the locale property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the macaddress property. ...

Gets the value of the macaddress property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the manufacturer property. ...

Gets the value of the manufacturer property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the model property. ...

Gets the value of the model property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the name property. ...

Gets the value of the name property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the netmask property. ...

Gets the value of the netmask property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the osname property. ...

Gets the value of the osname property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the ostype property. ...

Gets the value of the ostype property.

Returns

  • String
Titanium.Platform
( ) : Number
Gets the value of the processorCount property. ...

Gets the value of the processorCount property.

Returns

  • Number
Titanium.Platform
( ) : String
Gets the value of the runtime property. ...

Gets the value of the runtime property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the username property. ...

Gets the value of the username property.

Returns

  • String
Titanium.Platform
( ) : String
Gets the value of the version property. ...

Gets the value of the version property.

Returns

  • String
Titanium.Platform
( ) : Boolean
Returns whether the system settings are configured to show times in 24-hour format. ...

Returns whether the system settings are configured to show times in 24-hour format.

Returns

  • Boolean
Titanium.Platform
( url ) : Boolean
Opens this URL using the system's default application for its protocol. ...

Opens this URL using the system's default application for its protocol.

Parameters

  • url : String

    The url to open.

Returns

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

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

Multiple listeners can be registered for the same event, so the callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

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

Returns

  • void
Titanium.Platform
( batteryMonitoring )
Sets the value of the batteryMonitoring property. ...

Sets the value of the batteryMonitoring property.

Parameters

  • batteryMonitoring : Boolean

    New value for the property.

Returns

  • void
Sets the value of the bubbleParent property. ...

Sets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • bubbleParent : Boolean

    New value for the property.

Returns

  • void
Titanium.Platform
( identifierForAdvertising )
Sets the value of the identifierForAdvertising property. ...

Sets the value of the identifierForAdvertising property.

  • 7.0.0
  • 7.0.0

Parameters

  • identifierForAdvertising : String

    New value for the property.

Returns

  • void
Sets the value of the lifecycleContainer property. ...

Sets the value of the lifecycleContainer property.

  • 3.6.0

Parameters

Returns

  • void
Defined By

Events

Titanium.Platform
Fired when the battery state changes. ...

Fired when the battery state changes. This is measured in 5% increments on iPhone/iPad.

Properties

  • state : Number

    The battery state.

    This API can be assigned the following constants:

  • level : Number

    Percentage battery power level.

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

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

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •