Skip to content

Instantly share code, notes, and snippets.

@jonalter
Created June 3, 2011 16:08
Show Gist options
  • Select an option

  • Save jonalter/1006595 to your computer and use it in GitHub Desktop.

Select an option

Save jonalter/1006595 to your computer and use it in GitHub Desktop.
Android Urban Airship 1.0 documentation

urbanairship Module

Description

The UrbanAirship module is a way to connect to the UrbanAirship AirMail push notification service.

Accessing the urbanairship Module

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.

Reference

Functions

ti.urbanAirship.registerForPushNotifications({...})

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

Arguments

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 false if you don't pass this setting.)

Using this module

  • 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.)

Author

Nathaniel McCallum nmccallum@appcelerator.com, Appcelerator Inc.

License

TODO: Enter your license/legal information here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment