public abstract class

BaseIntentReceiver

extends BroadcastReceiver
java.lang.Object
   ↳ android.content.BroadcastReceiver
     ↳ com.urbanairship.push.BaseIntentReceiver

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 BaseIntentReceiver. Register the new class in the AndroidManifest.xml with the following intent filter:

 <receiver android:name="CustomIntentReceiver" 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" />

        <!-- Replace ${applicationId} with the package name for eclipse. -->
        <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

Constants
int RESULT_ACTIVITY_LAUNCHED Result code indicating an activity was launched during onNotificationActionOpened(android.content.Context, PushMessage, int, String, boolean) or onNotificationOpened(android.content.Context, PushMessage, int).
int RESULT_ACTIVITY_NOT_LAUNCHED Result code indicating an activity was not launched during onNotificationActionOpened(android.content.Context, PushMessage, int, String, boolean) or onNotificationOpened(android.content.Context, PushMessage, int).
Public Constructors
BaseIntentReceiver()
Public Methods
void onReceive(Context context, Intent intent)
Protected Methods
abstract void onBackgroundPushReceived(Context context, PushMessage message)
Called when a push is received that did not result in a notification being posted.
abstract void onChannelRegistrationFailed(Context context)
Called when channel registration fails.
abstract void onChannelRegistrationSucceeded(Context context, String channelId)
Called when channel registration succeeded.
abstract boolean onNotificationActionOpened(Context context, PushMessage message, int notificationId, String buttonId, boolean isForeground)
Called when a notification action button is opened.
void onNotificationDismissed(Context context, PushMessage message, int notificationId)
Called when a notification is dismissed from either swiping away the notification or from clearing all notifications.
abstract boolean onNotificationOpened(Context context, PushMessage message, int notificationId)
Called when a notification is opened.
abstract void onPushReceived(Context context, PushMessage message, int notificationId)
Called when a push is received.
[Expand]
Inherited Methods
From class android.content.BroadcastReceiver
From class java.lang.Object

Constants

public static final int RESULT_ACTIVITY_LAUNCHED

public static final int RESULT_ACTIVITY_NOT_LAUNCHED

Public Constructors

public BaseIntentReceiver ()

Public Methods

public void onReceive (Context context, Intent intent)

Protected Methods

protected abstract void onBackgroundPushReceived (Context context, PushMessage message)

Called when a push is received that did not result in a notification being posted.

Parameters
context The application context.
message The received push message.

protected abstract void onChannelRegistrationFailed (Context context)

Called when channel registration fails.

Parameters
context The application context.

protected abstract void onChannelRegistrationSucceeded (Context context, String channelId)

Called when channel registration succeeded.

Parameters
context The application context.
channelId The channel ID.

protected abstract boolean onNotificationActionOpened (Context context, PushMessage message, int notificationId, String buttonId, boolean isForeground)

Called when a notification action button is opened.

Parameters
context The application context.
message The push message associated with the notification.
notificationId The notification ID.
buttonId The button identifier.
isForeground If the notification action button is foreground or not. If false the application should not be launched.
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 void onNotificationDismissed (Context context, PushMessage message, int notificationId)

Called when a notification is dismissed from either swiping away the notification or from clearing all notifications.

Parameters
context The application context.
message The push message associated with the notification.
notificationId The notification ID.

protected abstract boolean onNotificationOpened (Context context, PushMessage message, int notificationId)

Called when a notification is opened.

Parameters
context The application context.
message The push message associated with the notification.
notificationId The notification ID.
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 abstract void onPushReceived (Context context, PushMessage message, int notificationId)

Called when a push is received.

Parameters
context The application context.
message The received push message.
notificationId The notification ID of the message posted in the notification center.