Push Notifications

Airship’s SDK provides a simple interface for managing push notifications within your Titanium application.

Enabling User Notifications

The Airship module makes a distinction between “user notifications,” which can be seen by the user, and invisible notifications that carry only data for the app to process. Enabling or disabling user notifications is a preference often best left up to the user, so by default, user notifications are disabled.

Enable user notifications
Airship.push.userNotificationsEnabled = true;

Listening for Events

The Airship.eventChannelCreated will be emitted when the channel is first created or updated due to registration changes.
Example Airship.eventChannelCreated
Airship.addEventListener(Airship.Airship.eventChannelCreated, function(e) {
    Ti.API.info('Channel created' + e.channelId);
The Airship.eventPushReceived will be emitted whenever a push is received when the application is foregrounded. The event will contain the notification, extras, and the notification ID (Android only). Example:
Example Airship.eventPushReceive
Airship.addEventListener(Airship.EVENT_PUSH_RECEIVED, function(e) {
    Ti.API.info('Push received' + JSON.stringify(e));