Package com.parse

Class ParsePushBroadcastReceiver


  • public class ParsePushBroadcastReceiver
    extends BroadcastReceiver
    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 #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.String ACTION_PUSH_DELETE
      The name of the Intent fired when a notification has been dismissed.
      static java.lang.String ACTION_PUSH_OPEN
      The name of the Intent fired when a notification has been opened.
      static java.lang.String ACTION_PUSH_RECEIVE
      The name of the Intent fired when a push has been received.
      static java.lang.String KEY_PUSH_CHANNEL
      The name of the Intent extra which contains a channel used to route this notification.
      static java.lang.String KEY_PUSH_DATA
      The name of the Intent extra which contains the JSON payload of the Notification.
      static java.lang.String PROPERTY_PUSH_ICON
      The name of the meta-data field used to override the icon used in Notifications.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void onReceive​(Context context, Intent intent)
      Delegates the generic onReceive event to a notification lifecycle event.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 be null.
        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
    • Constructor Detail

      • ParsePushBroadcastReceiver

        public ParsePushBroadcastReceiver()
    • Method Detail

      • onReceive

        public void onReceive​(Context context,
                              Intent intent)
        Delegates the generic onReceive event to a notification lifecycle event. Subclasses are advised to override the lifecycle events and not this method.
        Parameters:
        context - The Context in which the receiver is running.
        intent - An Intent containing the channel and data of the current push notification.
        See Also:
        ParsePushBroadcastReceiver#onPushReceive(Context, Intent), ParsePushBroadcastReceiver#onPushOpen(Context, Intent), ParsePushBroadcastReceiver#onPushDismiss(Context, Intent)