Firebase Messaging Breaks on Android Bundling

This one took a while

Posted on May 8, 2020

I had a big problem for over a month integrating invertase/react-native-firebase into my new app. Despite this being a React-Native library, the problem is very present even on native Android implementations. Here is the info:

The problem:

Firebase Messaging seemingly broke after generating a APK/AAB, rendering data messages sent to tokens lost in transit without an error or fail message.

The solution:

Adding the following line to the app's AndroidManifest.xml file:

For your copying pleasure:

<action android:name=""/>

Why this works:

Essentially, when we add this line we are explicitly telling Android that the class ReactNativeFirebaseMessagingService (which is built into the library and extends FirebaseMessagingService) should be the one handling any Firebase Messaging events that take place.

Likewise, this works for any other class that extends FirebaseMessagingService and handles the messaging.

Why did it break after being bundled?

The debugging/development state React-Native has makes connections based off of the Javascript implementations of native code bases, and only when the app is bundled does it actually compile down to native. Once this compilation is completed, the AndroidManifest.xml for that specific library should be merged (in some ways) to the AndroidManifest.xml for your app.

For whatever reason, the merge was not being made, and therefore this library was never referenced in the final bundle. By explicitly telling the app's AndroidManifest.xml to pay attention to that class, the messaging events are properly handled.

Helpful links: