How to identify if a FCM message is targeted to the FCM client handler or UrbanAirship handler

I'm using UrbanAirship for my mobile engagement tool in parallel to FCM on Android. Based on the UrbanAirship documentation(https://docs.urbanairship.com/platform/android/#fcm-setup), in case using my own FirebaseMessagingService I need to pass the remote message using AirshipFirebaseMessagingService.processMessageSync(this, remoteMessage);

How can I know that the message was not handled by UrbanAirship and I fallback to my own FCM notification builder? There is no return value for the processMessageSync method. I noticed that because UrbanAirship handles the message in a synchronous way, they are consuming and nullifying the notification field of the remoteMessage object. Seems strange to me that they haven't exposed any property or return value.

This is the code that worked for me (part of my AppFirebaseMessageService.java)

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

    AirshipFirebaseMessagingService.processMessageSync(this, remoteMessage);

    if (remoteMessage != null && remoteMessage.getNotification() != null) {
        handleInternalFcm(remoteMessage);
    }
}

Didn't find what you were looking for?

New post

Comments

1 comment

  • Thanks for the feedback. We will consider adding a result in the future.

     

    For now, you can see if the message contains a UA key and assume we will handle it:

    PushMessage pushMessage = new PushMessage(message.getData());
    if (pushMessage.containsAirshipKeys()) {
    // we will handle it
    }
    0

Please sign in to leave a comment.