firebase-unity-sdk
firebase-unity-sdk copied to clipboard
[Messaging] MessageReceived event cannot triggered when app is closed/background
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?
Still the same in Firebase version 8.9.0.
@google ,I order you guys to fix this within 3 days or I'll tell the CEO and fire you all, hum!
@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
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!
I'll try in the future.
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!
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.