Push Payload Details

Prev Next

Overview

Push Payload Details in Android allow developers to manage and utilize the notification payload to trigger various actions and handle events like notification receipt, opening, or dismissal. These payloads facilitate dynamic and personalized user experiences.

Use Case

  1. Purpose:

    • Extract and utilize data from push notifications to enhance app functionality.

    • Track user interactions with notifications (e.g., open, dismiss).

  2. Benefits:

    • Drive engagement with rich, actionable notifications.

    • Provide detailed analytics on user interaction with notifications.

Implementation Details

  1. Manifest Configuration:

    • Add a broadcast receiver in AndroidManifest.xml to handle push events:

      <receiver
          android:name=".MyPushBroadcastReceiver"
          android:enabled="true"
          android:exported="false">
          <intent-filter>
              <action android:name="com.appoxee.PUSH_OPENED"/>
              <action android:name="com.appoxee.PUSH_RECEIVED"/>
              <action android:name="com.appoxee.PUSH_DISMISSED"/>
              <category android:name="${applicationId}"/>
          </intent-filter>
      </receiver>
  2. Receiver Implementation:

    • Extend PushDataReceiver to handle push notification events:

      public class MyPushBroadcastReceiver extends PushDataReceiver {
      
          @Override
          public void onPushReceived(PushData pushData) {
              Log.d("PushNotification", "Push received: " + pushData);
          }
      
          @Override
          public void onPushOpened(PushData pushData) {
              Log.d("PushNotification", "Push opened: " + pushData);
          }
      
          @Override
          public void onPushDismissed(PushData pushData) {
              Log.d("PushNotification", "Push dismissed: " + pushData);
          }
      
          @Override
          public void onSilentPush(PushData pushData) {
              Log.d("PushNotification", "Silent push received: " + pushData);
          }
      }
  3. Notification Payload Handling:

    • Extract and utilize payload data within the overridden methods.

    • Access push metadata to trigger app-specific actions.

Keep in mind:

  • Ensure the PushDataReceiver handles all required actions (e.g., custom button clicks, silent push updates).

  • Log payload details for debugging and testing purposes.

  • Test notification events across various Android versions to ensure compatibility.