public class

AirshipReceiver

extends BroadcastReceiver
java.lang.Object
   ↳ android.content.BroadcastReceiver
     ↳ com.urbanairship.AirshipReceiver

Class Overview

Base intent receiver to process registration and push events from Urban Airship.

To listen for Urban Airship events, create a class that extends the AirshipReceiver. Register the new class in the AndroidManifest.xml with the following intent filter:

 <receiver android:name="CustomAirshipReceiver" exported="false">
 <intent-filter>
 <action android:name="com.urbanairship.push.CHANNEL_UPDATED" />
 <action android:name="com.urbanairship.push.OPENED" />
 <action android:name="com.urbanairship.push.RECEIVED" />
 <action android:name="com.urbanairship.push.DISMISSED" />

 <category android:name=${applicationId} />
 </intent-filter>
 </receiver>
 
 

Make sure the registered intent receiver is not exported to prevent it from receiving messages outside the application.

Summary

Nested Classes
class AirshipReceiver.ActionButtonInfo Contains info about a notification action button. 
class AirshipReceiver.NotificationInfo Contains information about a posted notification. 
Public Constructors
AirshipReceiver()
Public Methods
void onReceive(Context context, Intent intent)
Protected Methods
void onChannelCreated(Context context, String channelId)
Called when a channel ID is created.
void onChannelRegistrationFailed(Context context)
Called when channel registration fails.
void onChannelUpdated(Context context, String channelId)
Called when a channel ID is updated.
void onNotificationDismissed(Context context, AirshipReceiver.NotificationInfo notificationInfo)
Called when a notification is dismissed.
boolean onNotificationOpened(Context context, AirshipReceiver.NotificationInfo notificationInfo, AirshipReceiver.ActionButtonInfo actionButtonInfo)
Called when a notification action button is opened.
boolean onNotificationOpened(Context context, AirshipReceiver.NotificationInfo notificationInfo)
Called when a notification is opened.
void onNotificationPosted(Context context, AirshipReceiver.NotificationInfo notificationInfo)
Called when a notification is posted.
void onPushReceived(Context context, PushMessage message, boolean notificationPosted)
Called when a push is received.
[Expand]
Inherited Methods
From class android.content.BroadcastReceiver
From class java.lang.Object

Public Constructors

public AirshipReceiver ()

Public Methods

public void onReceive (Context context, Intent intent)

Protected Methods

protected void onChannelCreated (Context context, String channelId)

Called when a channel ID is created.

Parameters
context The application context.
channelId The channel ID.

protected void onChannelRegistrationFailed (Context context)

Called when channel registration fails.

Parameters
context The application context.

protected void onChannelUpdated (Context context, String channelId)

Called when a channel ID is updated.

Parameters
context The application context.
channelId The channel ID.

protected void onNotificationDismissed (Context context, AirshipReceiver.NotificationInfo notificationInfo)

Called when a notification is dismissed.

Parameters
context The application context.
notificationInfo The notification info.

protected boolean onNotificationOpened (Context context, AirshipReceiver.NotificationInfo notificationInfo, AirshipReceiver.ActionButtonInfo actionButtonInfo)

Called when a notification action button is opened.

Parameters
context The application context.
notificationInfo The notification info.
actionButtonInfo THe notification action button info.
Returns
  • true if the application was launched, otherwise false. If false is returned for a foreground notification action button, and autoLaunchApplication is enabled, the launcher activity will automatically be launched.

protected boolean onNotificationOpened (Context context, AirshipReceiver.NotificationInfo notificationInfo)

Called when a notification is opened.

Parameters
context The application context.
notificationInfo The notification info.
Returns
  • true if the application was launched, otherwise false. If false is returned, and autoLaunchApplication is enabled, the launcher activity will automatically be launched.

protected void onNotificationPosted (Context context, AirshipReceiver.NotificationInfo notificationInfo)

Called when a notification is posted.

Parameters
context The application context.
notificationInfo The notification info.

protected void onPushReceived (Context context, PushMessage message, boolean notificationPosted)

Called when a push is received.

Parameters
context The application context.
message The received push message.
notificationPosted true if a notification was posted for the push, otherwise {code false}. If the notification was posted onNotificationPosted(Context, NotificationInfo) will be called immediately after this method with the AirshipReceiver.NotificationInfo.