onMessageReceived

open fun onMessageReceived(context: Context, remoteMessage: RemoteMessage): Boolean

Processes incoming Firebase Cloud Messaging push notifications for Pushwoosh.

CRITICAL: Call this method from your custom onMessageReceived callback to let Pushwoosh handle its messages.

Without this call the SDK never sees the push. If your service renders the notification itself, the push still appears on screen and the integration looks healthy, while everything Pushwoosh does with a message is lost:

  • delivery and open statistics are never reported;
  • Rich Media attached to the push is not shown;
  • in-app messages triggered by the push are not displayed;
  • com.pushwoosh.notification.NotificationServiceExtension callbacks never fire;
  • silent system commands carried by the push are not executed.

Detect Pushwoosh messages with isPushwooshMessage and return right after forwarding: this method shows the notification itself, so falling through to your own renderer produces a duplicate. Example:



public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    // CRITICAL: Route Pushwoosh messages to Pushwoosh
    if (PushwooshFcmHelper.isPushwooshMessage(remoteMessage)) {
        PushwooshFcmHelper.onMessageReceived(this, remoteMessage);
        return;
    } else {
        // Handle other providers
    }
}

Return

true if the message was sent via Pushwoosh and was successfully processed; false otherwise

Parameters

context

application or service context

remoteMessage

Firebase Cloud Messaging remote message

See also

FirebaseMessagingService#onMessageReceived(RemoteMessage)