diff --git a/Assets/AddressableAssetsData/AddressableAssetSettings.asset b/Assets/AddressableAssetsData/AddressableAssetSettings.asset index 165e7bd0..84628646 100644 --- a/Assets/AddressableAssetsData/AddressableAssetSettings.asset +++ b/Assets/AddressableAssetsData/AddressableAssetSettings.asset @@ -15,7 +15,7 @@ MonoBehaviour: m_DefaultGroup: af10c9716f97a20469b8fc257eec4a13 m_currentHash: serializedVersion: 2 - Hash: ea94b3f7985f7214a5719239922767ff + Hash: 00000000000000000000000000000000 m_OptimizeCatalogSize: 0 m_BuildRemoteCatalog: 1 m_CatalogRequestsTimeout: 0 diff --git a/Assets/Plugins/Android/AndroidManifest.xml b/Assets/Plugins/Android/AndroidManifest.xml index a0cfcbea..62ec6a07 100644 --- a/Assets/Plugins/Android/AndroidManifest.xml +++ b/Assets/Plugins/Android/AndroidManifest.xml @@ -7,13 +7,14 @@ - + - + + \ No newline at end of file diff --git a/Assets/Plugins/Android/MessagingUnityPlayerActivity.java b/Assets/Plugins/Android/MessagingUnityPlayerActivity.java new file mode 100644 index 00000000..b9024923 --- /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 00000000..6e842e8a --- /dev/null +++ b/Assets/Plugins/Android/MessagingUnityPlayerActivity.java.meta @@ -0,0 +1,28 @@ +fileFormatVersion: 2 +guid: 1f13996192a0abc8cadaa39c71346066 +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/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 16c72b77..57e25c9c 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -141,7 +141,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 1.46 + bundleVersion: 1.47 preloadedAssets: - {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3} metroInputSource: 0