Push Notifications

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.userNotificationsEnabled = true;

Launch Notification

The notification that launched the application can be accessed with getLaunchNotification. The notification will contain the message, extras, and the notification ID. Example:

Example of getting the launch notification
// Passing true to getLaunchNotification will clear the notification and
// cause subsequent calls to return null.
var launchNotification = Airship.getLaunchNotification(true);

Listening for Events

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