firebase-unity-sdk
firebase-unity-sdk copied to clipboard
The same received event of Dynamic Links is called every time after maximizing app
Unity editor version: 2018.4.5f1 Firebase Unity SDK version: 6.6.0, 6.9.0, 6.10.0 (all not working) Firebase plugins in use (Auth, Database, etc.): Analytics, RemoteConfig, Crashlytics, DynamicLinks Additional SDKs you are using (Facebook, AdMob, etc.): Admob mediation, Facebook provider for Admob, Facebook SDK, Appsflyer, Android Native Pro, Platform you are using the Unity editor on (Mac, Windows, or Linux): Windows Platform you are targeting (iOS, Android, and/or desktop): Android Scripting Runtime (Mono, and/or IL2CPP): Mono and IL2CPP Dot.net: 4.x Devices: Xiaomi Mi 8, Google Pixel 4, Samsung S7, Samsung Note 4 Android version: from 6.0 to 10.0 (older not tested)
It's exactly the same bug as in https://github.com/firebase/quickstart-unity/issues/502
Steps to reproduce:
- Open App or do nothing
- Click dynamic link
- App is opened, link is correctly received
- Minimize app
- Maximize (but select app from background apps previews list, don't click on app icon, then it's working)
- Previously clicked link is received again (though nothing was clicked)
I have also tried clicking multiple times in different dynamic links in on app run. Behaviour is always the same. After maximize it fires only LAST clicked link. Not all. But expected behavior is to do nothing then.
Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? Yes. Mono, Unity 2018.4.5f1, Firebase 6.10.0.
What's the issue repro rate? 100%
There is a video with bug using quickstarts project: https://drive.google.com/file/d/1BJF_fx9gGeEZNZMJM1c440NmBi4HP-pf/view?usp=sharing
This issue does not seem to follow the issue template. Make sure you provide all the required information.
Thanks for reporting this @SebaDudzic. I was able to reproduce this issue on my end using the quickstart, so I've filed an internal bug report for this. I can't provide any timelines for the fix, so I'll leave this open.
I'm glad you have managed to reproduce that. It's a big issue for us. We have to implement a workaround that is not going to work perfectly. It has UX disadvantages. So please keep me informed if any fix will be available.
I have the same problem. How to fix it?
We are experiencing the same, harming our ability to successfully use dynamic links for social sharing replays in our game.
Hi @paulinon We have same issue. Do you have any ETA for fix of this issue? Thanks.
We're also suffering from this issue. When will we see a fix?
Same on our side. It seems clearing those Intent extras is enough to prevent the dynamic link to execute each time the app comes to the foreground:
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
var intent = activity.Call<AndroidJavaObject>("getIntent");
intent.Call("removeExtra", "com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA");
intent.Call("removeExtra", "com.google.android.gms.appinvite.REFERRAL_BUNDLE");
May be worth disposing those object, or enclosing them with using(){ }
Hi @paulinon. This bug is blocker for us on Android. Information about ETA of the fix will allow us to decide should we move to another Deep Link solution or wait until the fix. Could you please provide any information about status of internal issue? Is it still Open or InProgress? Thanks.
I have exactly the same problem
Any ETA when to expect a Fix? Problem is still present in latest version...
Still occurring in 6.14.1.
Has anyone been able to solve this? It is solvable or we need just wait for the fix?
Edit: The solution give by Johan worked like a charm: https://github.com/firebase/firebase-unity-sdk/issues/364
Not fixed yet. Johan's solution is what worked for me as well.
The new AndroidJavaClass("com.unity3d.player.UnityPlayer") dosent exist when i run it. Update: After doing some more testing this is what worked for me:
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using (AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
{
var intent = activity.Call<AndroidJavaObject>("getIntent");
intent.Call("removeExtra", "com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA");
intent.Call("removeExtra", "com.google.android.gms.appinvite.REFERRAL_BUNDLE");
}
}
Thanks Johan, your workaround worked!
As a workaround for us that works on both Android and iOS I implemented it in the following way by using intermediate class for triggering deep links:
- Subscribe to Firebase Dynamic Links as you usually do
- In your delegate method for subscription immediately unsubscribe
- Subscribe to Unity's
Application.deepLinkActivated
with the method that should trigger "step 4" - In the same delegate trigger your game logic that should happen by deep link open
Works with both deferred and regular deep links with no issues.
Disappointed, this is version 7.2.0 now, but no one on Firebase team care about it.
The issue persists in v8.1.0. So, I tried a workaround provided by eXisting, worked for me initially :)
As a workaround for us that works on both Android and iOS I implemented it in the following way by using intermediate class for triggering deep links:
- Subscribe to Firebase Dynamic Links as you usually do
- In your delegate method for subscription immediately unsubscribe
- Subscribe to Unity's
Application.deepLinkActivated
with the method that should trigger "step 4"- In the same delegate trigger your game logic that should happen by deep link open
Works with both deferred and regular deep links with no issues.
Nonetheless, the Dynamic Link was called again after the reopening the closed game app if:
- The Dynamic Link was called after unsubscribing a method from the DynamicLinkReceived event delegate.
To fix this issue, just subscribe an empty method to DynamicLinks.DynamicLinkReceived
after initially unsubscribing the original method based on eXisting's steps.
Just want to report that I'm using Firebase 8.2.0 and encountering this same issue on Android. Unity 2019.4.
. My game displays an in-app message . Tap on the button => dynamic link is received (the dynamic link is configured on Firebase In-App Messaging section)
-
OnDynamicLink(object sender, EventArgs args)
opens a web page withApplication.OpenURL
- Android browser is launched
- I press the back key to go back to the game
- The game is in the foreground for a second and it opens the browser again
- Debug.Log shows that
OnDynamicLink
is called every time the game is back to foreground - This loops forever!!! 😱
Same problem 2021. This loops forever :(
The new AndroidJavaClass("com.unity3d.player.UnityPlayer") dosent exist when i run it. Update: After doing some more testing this is what worked for me:
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) { var intent = activity.Call<AndroidJavaObject>("getIntent"); intent.Call("removeExtra", "com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA"); intent.Call("removeExtra", "com.google.android.gms.appinvite.REFERRAL_BUNDLE"); } }
What file can I add this code to?
@JohannCaron 's solution doesn't seem to work for me. The dynamic links still fire again on focus. Maybe I'm implementing it wrong? This is my code:
private void StartDynamicLinks()
{
DynamicLinks.DynamicLinkReceived += OnDynamicLinkReceived;
}
private void OnDynamicLinkReceived(object sender, EventArgs args)
{
var dynamicLinkEventArgs = args as ReceivedDynamicLinkEventArgs;
Debug.LogFormat("Received dynamic link {0}", dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString);
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using (var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
{
var intent = activity.Call<AndroidJavaObject>("getIntent");
intent.Call("removeExtra", "com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA");
intent.Call("removeExtra", "com.google.android.gms.appinvite.REFERRAL_BUNDLE");
}
}
// logic to handle link string goes here...
}
I'm using version 8.6.1 of the SDK on Unity 2020.3.16f1
@JohannCaron 's solution doesn't seem to work for me. The dynamic links still fire again on focus. Maybe I'm implementing it wrong? This is my code:
private void StartDynamicLinks() { DynamicLinks.DynamicLinkReceived += OnDynamicLinkReceived; } private void OnDynamicLinkReceived(object sender, EventArgs args) { var dynamicLinkEventArgs = args as ReceivedDynamicLinkEventArgs; Debug.LogFormat("Received dynamic link {0}", dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString); using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) { var intent = activity.Call<AndroidJavaObject>("getIntent"); intent.Call("removeExtra", "com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA"); intent.Call("removeExtra", "com.google.android.gms.appinvite.REFERRAL_BUNDLE"); } } // logic to handle link string goes here... }
I'm using version 8.6.1 of the SDK on Unity 2020.3.16f1
I use the same code and it works for me. So there should be no problem with implementation. I'm using:
- Firebase 8.1.0
- Unity 2020.3.15f2
- Samsung Galaxy S7
- Android 8.0.0
@JohannCaron 's solution doesn't seem to work for me. The dynamic links still fire again on focus. Maybe I'm implementing it wrong? This is my code:
private void StartDynamicLinks() { DynamicLinks.DynamicLinkReceived += OnDynamicLinkReceived; } private void OnDynamicLinkReceived(object sender, EventArgs args) { var dynamicLinkEventArgs = args as ReceivedDynamicLinkEventArgs; Debug.LogFormat("Received dynamic link {0}", dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString); using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) { var intent = activity.Call<AndroidJavaObject>("getIntent"); intent.Call("removeExtra", "com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA"); intent.Call("removeExtra", "com.google.android.gms.appinvite.REFERRAL_BUNDLE"); } } // logic to handle link string goes here... }
I'm using version 8.6.1 of the SDK on Unity 2020.3.16f1
This work for me too
Hello. I used a solution suggested by @JohannCaron to clear "extra" and it was working correctly. But this solution no longer works - after opening my app with link, I'm displaying form to the user and after closing keyboard "OnDynamicLinkReceived" is fired again.
I was trying to use this code to check if "extras" exist but both values are false.
var hasExtraDYNAMIC_LINK_DATA = intent.Call<bool>("hasExtra", "com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA");
var hasExtraREFERRAL_BUNDLE = intent.Call<bool>("hasExtra", "com.google.android.gms.appinvite.REFERRAL_BUNDLE");
I suspect that those extras names changed but have no idea how to list those extras.
My setup:
- Firebase 9.4.0
- Unity 2021.3
- Android 12.0
- Samsung A53
Any update on this?
Sometimes I get the feeling Google is about to shutdown Firebase as a whole... There's no way such a trivial bug is still happening after almost 3 years
@paulinon How in the world is this still an active problem with no official solution!?!? This is insane, and needs to be fixed.
Still happening. Android 13. Firebase 10.7.0. Unity 2021.3.24f1.
Any updates about this issue?