Class ParsePushBroadcastReceiver
- java.lang.Object
-
- BroadcastReceiver
-
- com.parse.ParsePushBroadcastReceiver
-
public class ParsePushBroadcastReceiver extends BroadcastReceiverABroadcastReceiverfor rendering and reacting to to Notifications.This
BroadcastReceivermust be registered in order to use theParsePushsubscription methods. As a security precaution, the intent filters for thisBroadcastReceivermust not be exported. Add the following lines to yourAndroidManifest.xmlfile, inside the <application> element to properly register theParsePushBroadcastReceiver:<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
ParsePushBroadcastReceiveris 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/iconmay 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,
ParsePushBroadcastReceivercan be subclassed. When providing your own implementation ofParsePushBroadcastReceiver, be sure to changecom.parse.PushBroadcastReceiverto 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#onPushReceive(Context, Intent),#onPushOpen(Context, Intent), or#onPushDismiss(Context, Intent). To make minor changes to the appearance of a notification, override#getSmallIconId(Context, Intent)or#getLargeIcon(Context, Intent). To completely change the Notification generated, override#getNotification(Context, Intent). To change the NotificationChannel generated, override#getNotificationChannel(Context, Intent). To change how the NotificationChannel is created, override#createNotificationChannel(Context, NotificationChannel). To change the Activity launched when a user opens a Notification, override#getActivity(Context, Intent).
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACTION_PUSH_DELETEThe name of the Intent fired when a notification has been dismissed.static java.lang.StringACTION_PUSH_OPENThe name of the Intent fired when a notification has been opened.static java.lang.StringACTION_PUSH_RECEIVEThe name of the Intent fired when a push has been received.static java.lang.StringKEY_PUSH_CHANNELThe name of the Intent extra which contains a channel used to route this notification.static java.lang.StringKEY_PUSH_DATAThe name of the Intent extra which contains the JSON payload of the Notification.static java.lang.StringPROPERTY_PUSH_ICONThe name of the meta-data field used to override the icon used in Notifications.
-
Constructor Summary
Constructors Constructor Description ParsePushBroadcastReceiver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonReceive(Context context, Intent intent)Delegates the genericonReceiveevent to a notification lifecycle event.
-
-
-
Field Detail
-
KEY_PUSH_CHANNEL
public static final java.lang.String KEY_PUSH_CHANNEL
The name of the Intent extra which contains a channel used to route this notification. May benull.- See Also:
- Constant Field Values
-
KEY_PUSH_DATA
public static final java.lang.String KEY_PUSH_DATA
The name of the Intent extra which contains the JSON payload of the Notification.- See Also:
- Constant Field Values
-
ACTION_PUSH_RECEIVE
public static final java.lang.String ACTION_PUSH_RECEIVE
The name of the Intent fired when a push has been received.- See Also:
- Constant Field Values
-
ACTION_PUSH_OPEN
public static final java.lang.String ACTION_PUSH_OPEN
The name of the Intent fired when a notification has been opened.- See Also:
- Constant Field Values
-
ACTION_PUSH_DELETE
public static final java.lang.String ACTION_PUSH_DELETE
The name of the Intent fired when a notification has been dismissed.- See Also:
- Constant Field Values
-
PROPERTY_PUSH_ICON
public static final java.lang.String PROPERTY_PUSH_ICON
The name of the meta-data field used to override the icon used in Notifications.- See Also:
- Constant Field Values
-
-
Method Detail
-
onReceive
public void onReceive(Context context, Intent intent)Delegates the genericonReceiveevent to a notification lifecycle event. Subclasses are advised to override the lifecycle events and not this method.- Parameters:
context- TheContextin which the receiver is running.intent- AnIntentcontaining the channel and data of the current push notification.- See Also:
ParsePushBroadcastReceiver#onPushReceive(Context, Intent),ParsePushBroadcastReceiver#onPushOpen(Context, Intent),ParsePushBroadcastReceiver#onPushDismiss(Context, Intent)
-
-