The UrbanAirship module is a way to connect to the UrbanAirship AirMail push notification service.
To access this module from JavaScript, you would do the following:
var urbanairship = require("ti.urbanAirship");
The urbanairship variable is a reference to the Module object.
This function is nearly identical to Titanium.Network.registerForPushNotifications().
The differences are as follows:
- It does not take the 'types' property.
- You must pass config.urbanAirship.appKey, which is your UA Application Key.
- If you wish for your application come forward (in case it's in the background) when a user clicks (taps) an Urban Airship notification, you should also pass config.urbanAirship.showAppOnClick with a value of
true.
It registers the device with UrbanAirship and calls the callbacks during one of the following events:
- Registration success
- Registration failure
- A new push message is received
- The user clicks on the android notification
Takes one argument, a dictionary with keys:
- success[function]: Called upon successful registration (e.deviceToken contains the APID).
- error[function]: Called upon registration failure.
- callback[function]: Called when a new push is received or the user clicks the Android notification. The event object contains the following fields: message[string]: The message. payload[string]: The payload of the push message. clicked[bool]: Whether the event is the result of a notification click or not.
- urbanAirship[object]: Contains UA keys/values, with urbanAirship.appKey[string] being your UA Application Key and urbanAirship.showAppOnClick being a true/false to indicate if your application should come forward (in case it's in the background) when a user clicks (taps) an Urban Airship notification. (Default is
falseif you don't pass this setting.)
- Put the module zip file into the root folder of your Titanium application.
- Set the
<module>element in tiapp.xml, such as this: ti.urbanAirship - Set the
<receivers>sub-element in the<android><manifest><application>element of tiapp.xml. Titanium will then put that in the generated AndroidManifest.xml for your application. tiapp.xml example: - At the Urban Airship website, on the admin page for your application, don't forget to set the "Android Package" field to the id of your Titanium application, which automatically becomes the package name of the generated Android app (e.g., com.yourname.yourapp.)
Nathaniel McCallum nmccallum@appcelerator.com, Appcelerator Inc.
TODO: Enter your license/legal information here.