firebase-unity-sdk icon indicating copy to clipboard operation
firebase-unity-sdk copied to clipboard

[Messaging] MessageReceived event cannot triggered when app is closed/background

Open ceyhunkeklik opened this issue 2 years ago • 5 comments

Firebase Version: 8.8.0 Unity Version: 2020.3.26f1

Hi, I've read many times to the integration guide and tried many times to handle data messages in the background. Unfortunately, I failed. But it works if app is active and foreground.

I don't use custom entry point. Therefore, as you can see in the guide, I don't need to take any action.

If you are not using a custom entry point this replacement happens automatically and you should not have to take any additional action.

But even so, I checked the Manifest file through from the generated/decompiled APK file. It has the following lines that are necessary.

<service android:directBootAware="true" android:exported="false" android:name="com.google.firebase.messaging.FirebaseMessagingService">
    <intent-filter android:priority="-500">
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

<service android:exported="false" android:name="com.google.firebase.messaging.cpp.ListenerService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

<service android:exported="false" android:name="com.google.firebase.messaging.cpp.RegistrationIntentService"/>

Also, I've used the following payloads to try it.

{
    "registration_ids": [
        "<token>"
    ],
    "data": {
        "testAttribute": "00000000-0000-0000-0000-00000000"
    }
}
{
    "to": "<token>",
    "data": {
        "testAttribute": "00000000-0000-0000-0000-00000000"
    }
}

Do you have an idea?

ceyhunkeklik avatar Apr 05 '22 12:04 ceyhunkeklik

Still the same in Firebase version 8.9.0.

ceyhunkeklik avatar Apr 12 '22 13:04 ceyhunkeklik

@google ,I order you guys to fix this within 3 days or I'll tell the CEO and fire you all, hum!

825126369 avatar Apr 19 '22 10:04 825126369

@ceyhunkeklik

Sorry to get back to you this late.

Does this still occur to you with later versions of SDK? There are a couple of patches in FCM

https://firebase.google.com/support/release-notes/unity#fcm https://firebase.google.com/support/release-notes/unity#fcm_1

Also, FCM SDK usually would attempt to create Assets/Plugins/Android/AndroidManifest.xml like this

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.google.firebase.unity.analytics.testapp" android:versionCode="1" android:versionName="1.0">
  <application android:label="@string/app_name" android:icon="@drawable/app_icon">
    <!-- The MessagingUnityPlayerActivity is a class that extends
         UnityPlayerActivity to work around a known issue when receiving
         notification data payloads in the background. -->
    <activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <service android:name="com.google.firebase.messaging.MessageForwardingService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="false"></service>
  </application>
</manifest>

It only generates one if this files does not exist. If you already have this file in your project, try to merge this into your own AndroidManifest.xml. This is required to receive message when app is in the background.

Let me know

chkuang-g avatar Oct 10 '22 04:10 chkuang-g

Hey @ceyhunkeklik. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Oct 17 '22 01:10 google-oss-bot

I'll try in the future.

ceyhunkeklik avatar Oct 18 '22 13:10 ceyhunkeklik

Hey @ceyhunkeklik. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Nov 11 '22 02:11 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@ceyhunkeklik if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Nov 18 '22 02:11 google-oss-bot