getNotificationIntent

open fun getNotificationIntent(data: PushMessage): Intent

Creates the intent that will be fired when the user taps the notification.

By default, this method returns an intent that opens the app and triggers push notification click tracking. Override this method to customize what happens when users tap notifications, such as opening a specific activity or deep link.

Important: To maintain push statistics tracking, your custom intent should still include the notification bundle data using EXTRA_NOTIFICATION_BUNDLE. Example - Open specific activity on notification tap:


	  
	  public Intent getNotificationIntent(@NonNull PushMessage data) {
	      // Parse custom data to determine target screen
	      String customData = data.getCustomData();
	      Intent intent;
	
	      try {
	          JSONObject json = new JSONObject(customData);
	          String screen = json.optString("target_screen");
	
	          if ("profile".equals(screen)) {
	              // Open profile activity directly
	              intent = new Intent(getApplicationContext(), ProfileActivity.class);
	          } else if ("chat".equals(screen)) {
	              // Open chat with specific user
	              String userId = json.optString("user_id");
	              intent = new Intent(getApplicationContext(), ChatActivity.class);
	              intent.putExtra("user_id", userId);
	          } else {
	              // Default: open main activity
	              intent = new Intent(getApplicationContext(), MainActivity.class);
	          }
	      } catch (Exception e) {
	          intent = new Intent(getApplicationContext(), MainActivity.class);
	      }
	
	      // Required: Attach notification data for tracking
	      intent.putExtra(NotificationIntentHelper.EXTRA_NOTIFICATION_BUNDLE, data.toBundle());
	      intent.setAction(Long.toString(System.currentTimeMillis()));
	      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
	
	      return intent;
	  }
	
Example - Handle deep links:

	  
	  public Intent getNotificationIntent(@NonNull PushMessage data) {
	      String customData = data.getCustomData();
	      Intent intent;
	
	      try {
	          JSONObject json = new JSONObject(customData);
	          String deepLink = json.optString("deep_link");
	
	          if (!TextUtils.isEmpty(deepLink)) {
	              // Handle deep link
	              intent = new Intent(Intent.ACTION_VIEW, Uri.parse(deepLink));
	          } else {
	              intent = new Intent(getApplicationContext(), MainActivity.class);
	          }
	      } catch (Exception e) {
	          intent = new Intent(getApplicationContext(), MainActivity.class);
	      }
	
	      intent.putExtra(NotificationIntentHelper.EXTRA_NOTIFICATION_BUNDLE, data.toBundle());
	      intent.setAction(Long.toString(System.currentTimeMillis()));
	
	      return intent;
	  }
	

Return

Intent to be fired when the user taps the notification

Parameters

data

Push notification data with message content and custom payload

See also

NotificationIntentHelper#EXTRA_NOTIFICATION_BUNDLE