From a15b08df0c3e7af655eec9be219b48a3ecdfbc84 Mon Sep 17 00:00:00 2001 From: Savya Bikram Shah Date: Sun, 7 Jun 2026 18:28:00 +0545 Subject: [PATCH] Fix --- .../firebase-messaging-unity-13.11.0.aar | Bin .../firebase-messaging-unity-13.11.0.pom | 0 Assets/Plugins/Android/AndroidManifest.xml | 3 +- .../res/values/crashlytics_build_id.xml | 2 +- .../Android/MessagingUnityPlayerActivity.java | 82 ++++++++++++++++++ .../MessagingUnityPlayerActivity.java.meta | 28 ++++++ Assets/Settings/Build Profiles/Android™.asset | 2 +- 7 files changed, 114 insertions(+), 3 deletions(-) mode change 100644 => 100755 Assets/GeneratedLocalRepo/Firebase/m2repository/com/google/firebase/firebase-messaging-unity/13.11.0/firebase-messaging-unity-13.11.0.aar mode change 100644 => 100755 Assets/GeneratedLocalRepo/Firebase/m2repository/com/google/firebase/firebase-messaging-unity/13.11.0/firebase-messaging-unity-13.11.0.pom create mode 100644 Assets/Plugins/Android/MessagingUnityPlayerActivity.java create mode 100644 Assets/Plugins/Android/MessagingUnityPlayerActivity.java.meta diff --git a/Assets/GeneratedLocalRepo/Firebase/m2repository/com/google/firebase/firebase-messaging-unity/13.11.0/firebase-messaging-unity-13.11.0.aar b/Assets/GeneratedLocalRepo/Firebase/m2repository/com/google/firebase/firebase-messaging-unity/13.11.0/firebase-messaging-unity-13.11.0.aar old mode 100644 new mode 100755 diff --git a/Assets/GeneratedLocalRepo/Firebase/m2repository/com/google/firebase/firebase-messaging-unity/13.11.0/firebase-messaging-unity-13.11.0.pom b/Assets/GeneratedLocalRepo/Firebase/m2repository/com/google/firebase/firebase-messaging-unity/13.11.0/firebase-messaging-unity-13.11.0.pom old mode 100644 new mode 100755 diff --git a/Assets/Plugins/Android/AndroidManifest.xml b/Assets/Plugins/Android/AndroidManifest.xml index faf31d4..cdb773c 100644 --- a/Assets/Plugins/Android/AndroidManifest.xml +++ b/Assets/Plugins/Android/AndroidManifest.xml @@ -2,12 +2,13 @@ - + + diff --git a/Assets/Plugins/Android/FirebaseCrashlytics.androidlib/res/values/crashlytics_build_id.xml b/Assets/Plugins/Android/FirebaseCrashlytics.androidlib/res/values/crashlytics_build_id.xml index 90be61f..6352716 100644 --- a/Assets/Plugins/Android/FirebaseCrashlytics.androidlib/res/values/crashlytics_build_id.xml +++ b/Assets/Plugins/Android/FirebaseCrashlytics.androidlib/res/values/crashlytics_build_id.xml @@ -1 +1 @@ -b1198bcb-9e68-42ca-afdc-de38c0753861 +0a4c6c8f-8290-4f0a-8af5-899267e3f184 diff --git a/Assets/Plugins/Android/MessagingUnityPlayerActivity.java b/Assets/Plugins/Android/MessagingUnityPlayerActivity.java new file mode 100644 index 0000000..b902492 --- /dev/null +++ b/Assets/Plugins/Android/MessagingUnityPlayerActivity.java @@ -0,0 +1,82 @@ +/* + * This file is generated by the FirebaseMessagingActivityGenerator script. + * Refer to that script for more information. + */ + +package com.google.firebase; + +import android.content.Intent; +import android.os.Bundle; +import com.google.firebase.messaging.MessageForwardingService; +import com.unity3d.player.UnityPlayerGameActivity; + +/** + * MessagingUnityPlayerActivity is a UnityPlayerGameActivity that updates its intent when new intents + * are sent to it. + * + * This is a workaround for a known issue that prevents Firebase Cloud Messaging from responding to + * data payloads when both a data and notification payload are sent to the app while it is in the + * background. + */ +public class MessagingUnityPlayerActivity extends UnityPlayerGameActivity { + // The key in the intent's extras that maps to the incoming message's message ID. Only sent by + // the server, GmsCore sends EXTRA_MESSAGE_ID_KEY below. Server can't send that as it would get + // stripped by the client. + private static final String EXTRA_MESSAGE_ID_KEY_SERVER = "message_id"; + + // An alternate key value in the intent's extras that also maps to the incoming message's message + // ID. Used by upstream, and set by GmsCore. + private static final String EXTRA_MESSAGE_ID_KEY = "google.message_id"; + + // The key in the intent's extras that maps to the incoming message's sender value. + private static final String EXTRA_FROM = "google.message_id"; + + /** + * Workaround for when a message is sent containing both a Data and Notification payload. + * + *

When the app is in the background, if a message with both a data and notification payload is + * received the data payload is stored on the Intent passed to onNewIntent. By default, that + * intent does not get set as the Intent that started the app, so when the app comes back online + * it doesn't see a new FCM message to respond to. As a workaround, we override onNewIntent so + * that it sends the intent to the MessageForwardingService which forwards the message to the + * FirebaseMessagingService which in turn sends the message to the application. + */ + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + // If we do not have a 'from' field this intent was not a message and should not be handled. It + // probably means this intent was fired by tapping on the app icon. + Bundle extras = intent.getExtras(); + if (extras == null) { + return; + } + String from = extras.getString(EXTRA_FROM); + String messageId = extras.getString(EXTRA_MESSAGE_ID_KEY); + if (messageId == null) { + messageId = extras.getString(EXTRA_MESSAGE_ID_KEY_SERVER); + } + if (from != null && messageId != null) { + Intent message = new Intent(this, MessageForwardingService.class); + message.setAction(MessageForwardingService.ACTION_REMOTE_INTENT); + message.putExtras(intent); + message.setData(intent.getData()); + MessageForwardingService.enqueueWork(this, message); + } + setIntent(intent); + } + + /** + * Dispose of the mUnityPlayer when restarting the app. + * + *

This ensures that when the app starts up again it does not start with stale data. + */ + @Override + protected void onCreate(Bundle savedInstanceState) { + if (mUnityPlayer != null) { + mUnityPlayer.destroy(); + mUnityPlayer = null; + } + super.onCreate(savedInstanceState); + } +} \ No newline at end of file diff --git a/Assets/Plugins/Android/MessagingUnityPlayerActivity.java.meta b/Assets/Plugins/Android/MessagingUnityPlayerActivity.java.meta new file mode 100644 index 0000000..34f71c7 --- /dev/null +++ b/Assets/Plugins/Android/MessagingUnityPlayerActivity.java.meta @@ -0,0 +1,28 @@ +fileFormatVersion: 2 +guid: e79bd7233f70e4addb0fced7e984ef06 +labels: +- FirebaseMessagingActivityGenerated +PluginImporter: + externalObjects: {} + serializedVersion: 3 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + Android: + enabled: 1 + settings: {} + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Settings/Build Profiles/Android™.asset b/Assets/Settings/Build Profiles/Android™.asset index 0ba8093..72d36b1 100644 --- a/Assets/Settings/Build Profiles/Android™.asset +++ b/Assets/Settings/Build Profiles/Android™.asset @@ -49,7 +49,7 @@ MonoBehaviour: m_ExportAsGoogleAndroidProject: 0 m_DebugSymbolLevel: 4 m_DebugSymbolFormat: 5 - m_CurrentDeploymentTargetId: __builtin__target_default + m_CurrentDeploymentTargetId: KBUKQ4PNCAOBS8YH m_BuildType: 2 m_LinkTimeOptimization: 0 m_BuildAppBundle: 1