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.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
- EVENT_CHANNEL_UPDATED
- The
EVENT_CHANNEL_UPDATED
will be emitted when the channel is first created or updated due to registration changes.
Example EVENT_CHANNEL_UPDATED
Airship.addEventListener(Airship.EVENT_CHANNEL_UPDATED, function(e) {
Ti.API.info('Channel Updated' + Airship.channelId);
});
- EVENT_PUSH_RECEIVED
- 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:
Example EVENT_PUSH_RECEIVED
Airship.addEventListener(Airship.EVENT_PUSH_RECEIVED, function(e) {
Ti.API.info('Push received' + e.message);
});
Feedback
Was this page helpful?
Thank you
Thanks for your feedback!
Tell Us MoreThank you
We will try harder!
Tell Us MoreCategories