Skip to content

[Bug] [Messaging] Android OnMessageReceived not being called when app is in background only #1020

@MartinGonzalez

Description

@MartinGonzalez
  • Unity editor version: 2019.4.16
  • Firebase Unity SDK version: 7.0.2
  • Source you installed the SDK: Unity Package Manager
  • Problematic Firebase Component: Messaging
  • Other Firebase Components in use: Crashltycs, Analytics, Dynamic Links
  • Additional SDKs you are using: Facebook, Appsflyer, Braze
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: iOS, Android
  • Scripting Runtime: IL2CPP

The problem is happening only on Android 8 or greater, when the app is in background only. (When app is dead is working correctly)

In Android, seems to be greater than Android 7, notification arrives correctly and when tapping it opens the app but event OnMessageReceived is not being executed.

I've tested on two devices, one with Android 7 and other Android 9, in Android 7 works everything fine but in Android 9 happens what I described above. I've read the from Android 8 or greater there is some king of priority when applications are in background but we could not found some fix to this.

We have our own Activity so we added the following code that is being called correctly and working on Android 7

@Override
    public void onNewIntent(Intent intent) {
        Log.d(LogTag, "Firebase on new Intent");
        Activity activity = UnityPlayer.currentActivity;
        Intent message = new Intent(activity, MessageForwardingService.class);
        message.setAction(MessageForwardingService.ACTION_REMOTE_INTENT);
        message.putExtras(intent);
        message.setData(intent.getData());
        activity.startService(message);
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions