Package com.mparticle

Class MPReceiver


  • public class MPReceiver
    extends android.content.BroadcastReceiver
    Core BroadcastReceiver used to support push notifications. Handles the following Intent actions:
    • com.google.android.c2dm.intent.RECEIVE
    • android.intent.action.PACKAGE_REPLACED
    • android.intent.action.BOOT_COMPLETED
    This BroadcastReceiver must be specified within the <application> block of your application's AndroidManifest.xml file:
     
      <receiver android:exported="true" android:name="com.mparticle.MPReceiver"
          android:permission="com.google.android.c2dm.permission.SEND" >
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
              <action android:name="com.google.android.c2dm.intent.UNREGISTER"/>
              <!-- Use your application's package name as the category -->
              <category android:name="<YOUR_PACKAGE_NAME_HERE>" />
          </intent-filter>
          <!-- The FCM registration ID could change on an app upgrade, this filter will allow mParticle to re-register for push notifications if necessary. -->
          <intent-filter>
              <action android:name="android.intent.action.PACKAGE_REPLACED" />
              <!-- Use your application's package name as the path -->
              <data android:path="<YOUR_PACKAGE_NAME_HERE>"
                  android:scheme="package" />
          </intent-filter>
          <!-- The FCM registration ID could change if the device's Android version changes, this filter will allow mParticle to re-register for push notifications if necessary. -->
          <intent-filter>
              <action android:name="android.intent.action.BOOT_COMPLETED" />
          </intent-filter>
     </receiver> 
    • Nested Class Summary

      • Nested classes/interfaces inherited from class android.content.BroadcastReceiver

        android.content.BroadcastReceiver.PendingResult
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MPARTICLE_IGNORE  
    • Constructor Summary

      Constructors 
      Constructor Description
      MPReceiver()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean onNotificationReceived​(ProviderCloudMessage message)
      Override this method to listen for when a notification has been received.
      protected boolean onNotificationTapped​(ProviderCloudMessage message)
      Override this method to listen for when a notification has been tapped or acted on.
      void onReceive​(android.content.Context context, android.content.Intent intent)  
      • 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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MPARTICLE_IGNORE

        @NonNull
        public static final java.lang.String MPARTICLE_IGNORE
        See Also:
        Constant Field Values
    • Constructor Detail

      • MPReceiver

        public MPReceiver()
    • Method Detail

      • onReceive

        public final void onReceive​(@NonNull
                                    android.content.Context context,
                                    @NonNull
                                    android.content.Intent intent)
        Specified by:
        onReceive in class android.content.BroadcastReceiver
      • onNotificationReceived

        protected boolean onNotificationReceived​(@NonNull
                                                 ProviderCloudMessage message)
        Override this method to listen for when a notification has been received.
        Parameters:
        message - The message that was received.
        Returns:
        True if you would like to handle this notification, False if you would like the mParticle to generate and show a Notification.
      • onNotificationTapped

        protected boolean onNotificationTapped​(@NonNull
                                               ProviderCloudMessage message)
        Override this method to listen for when a notification has been tapped or acted on.
        Parameters:
        message - The message that was tapped.
        Returns:
        True if you would like to consume this tap/action, False if the mParticle SDK should attempt to handle it.