|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectandroid.content.BroadcastReceiver
com.parse.ParsePushBroadcastReceiver
public class ParsePushBroadcastReceiver
A BroadcastReceiver for rendering and reacting to to Notifications.
This BroadcastReceiver must be registered in order to use the ParsePush
subscription
methods. As a security precaution, the intent filters for this BroadcastReceiver must not be
exported. Add the following lines to your AndroidManifest.xml
file, inside the
<application> element to properly register the ParsePushBroadcastReceiver:
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported=false> <intent-filter> <action android:name="com.parse.push.intent.RECEIVE" /> <action android:name="com.parse.push.intent.OPEN" /> <action android:name="com.parse.push.intent.DELETE" /> </intent-filter> </receiver>The ParsePushBroadcastReceiver is designed to provide maximal configurability with minimal effort. To customize the push icon, add the following line as a child of your <application> element:
<meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/icon"/>where
drawable/icon
may be the path to any drawable resource. The
Android style guide
for Notifications suggests that push icons should be flat monochromatic images.
To achieve further customization, ParsePushBroadcastReceiver can be subclassed. When providing your
own implementation of ParsePushBroadcastReceiver, be sure to change
com.parse.PushBroadcastReceiver
to the name of your custom subclass in your
AndroidManifest.xml. You can intercept and override the behavior of entire portions of the
push lifecycle by overriding ParsePushBroadcastReceiver.onPushReceive(Context, Intent)
,
ParsePushBroadcastReceiver.onPushOpen(Context, Intent)
, or
ParsePushBroadcastReceiver.onPushDismiss(Context, Intent)
. To make minor changes to the
appearance of a notification, override ParsePushBroadcastReceiver.getSmallIconId(Context, Intent)
or ParsePushBroadcastReceiver.getLargeIcon(Context, Intent)
. To completely change the
Notification generated, override ParsePushBroadcastReceiver.getNotification(Context, Intent)
.
To change the Activity launched when a user opens a Notification, override
ParsePushBroadcastReceiver.getActivity(Context, Intent)
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class android.content.BroadcastReceiver |
---|
BroadcastReceiver.PendingResult |
Field Summary | |
---|---|
static String |
ACTION_PUSH_DELETE
The name of the Intent fired when a notification has been dismissed. |
static String |
ACTION_PUSH_OPEN
The name of the Intent fired when a notification has been opened. |
static String |
ACTION_PUSH_RECEIVE
The name of the Intent fired when a push has been received. |
static String |
KEY_PUSH_CHANNEL
The name of the Intent extra which contains a channel used to route this notification. |
static String |
KEY_PUSH_DATA
The name of the Intent extra which contains the JSON payload of the Notification. |
static String |
PROPERTY_PUSH_ICON
The name of the meta-data field used to override the icon used in Notifications. |
protected static int |
SMALL_NOTIFICATION_MAX_CHARACTER_LIMIT
|
Constructor Summary | |
---|---|
ParsePushBroadcastReceiver()
|
Method Summary | |
---|---|
protected Class<? extends Activity> |
getActivity(Context context,
Intent intent)
Used by onPushOpen to determine which activity to launch or insert into the back stack. |
protected Bitmap |
getLargeIcon(Context context,
Intent intent)
Retrieves the large icon to be used in a Notification. |
protected Notification |
getNotification(Context context,
Intent intent)
Creates a Notification with reasonable defaults. |
protected int |
getSmallIconId(Context context,
Intent intent)
Retrieves the small icon to be used in a Notification. |
protected void |
onPushDismiss(Context context,
Intent intent)
Called when the push notification is dismissed. |
protected void |
onPushOpen(Context context,
Intent intent)
Called when the push notification is opened by the user. |
protected void |
onPushReceive(Context context,
Intent intent)
Called when the push notification is received. |
void |
onReceive(Context context,
Intent intent)
Delegates the generic onReceive event to a notification lifecycle event. |
Methods inherited from class android.content.BroadcastReceiver |
---|
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String KEY_PUSH_CHANNEL
public static final String KEY_PUSH_DATA
public static final String ACTION_PUSH_RECEIVE
public static final String ACTION_PUSH_OPEN
public static final String ACTION_PUSH_DELETE
public static final String PROPERTY_PUSH_ICON
protected static final int SMALL_NOTIFICATION_MAX_CHARACTER_LIMIT
Constructor Detail |
---|
public ParsePushBroadcastReceiver()
Method Detail |
---|
public void onReceive(Context context, Intent intent)
onReceive
in class BroadcastReceiver
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.ParsePushBroadcastReceiver.onPushReceive(Context, Intent)
,
ParsePushBroadcastReceiver.onPushOpen(Context, Intent)
,
ParsePushBroadcastReceiver.onPushDismiss(Context, Intent)
protected void onPushReceive(Context context, Intent intent)
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.protected void onPushDismiss(Context context, Intent intent)
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.protected void onPushOpen(Context context, Intent intent)
ParsePushBroadcastReceiver.getActivity(Context, Intent)
. If the
push contains a 'uri' parameter, an Intent is fired to view that URI with the Activity returned
by getActivity() in the back stack.
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.protected Class<? extends Activity> getActivity(Context context, Intent intent)
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.
protected int getSmallIconId(Context context, Intent intent)
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.
protected Bitmap getLargeIcon(Context context, Intent intent)
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.
protected Notification getNotification(Context context, Intent intent)
context
- The Context in which the receiver is running.intent
- An Intent containing the channel and data of the current push notification.
ParsePushBroadcastReceiver.onPushReceive(Context, Intent)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |