Hi Naren!
I'd love to know whether you believe that you've found a bug in dynamic links (ie: it's not behaving as you expected) or if you're just asking for general device on a specific user journey.
To answer your question directly, in scripts where I care about whether or not I'm in the background I typically use the
OnApplicationPause callback. So you could have something like:
```
using System;
using TMPro;
using Firebase.DynamicLinks;
using UnityEngine;
namespace Firebase.QA.Tests
{
internal sealed class DynamicLinkTest : MonoBehaviour
{
[SerializeField] internal TextMeshProUGUI MyTextField;
private void OnEnable()
{
DynamicLinks.DynamicLinkReceived += onDynamicLinkReceived;
MyTextField.SetText("initiated");
}
private void onDynamicLinkReceived(object _sender, EventArgs _args)
{
ReceivedDynamicLinkEventArgs dynamicLinkEventArgs = _args as ReceivedDynamicLinkEventArgs;
Debug.LogFormat("Received dynamic link {0}",
dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString);
MyTextField.SetText(dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString);
}
private void OnDisable()
{
DynamicLinks.DynamicLinkReceived -= onDynamicLinkReceived;
}
private void OnApplicationPause(bool paused)
{
if (paused)
{
// do something here. Set a variable, unregister the callback, &c
}
else
{
// do something here. Set a variable, register the callback, &c
}
}
}
}
```
If that doesn't help, I just need a little more information about what's happening and what you want to achieve. I can certainly dive into more details (ex: is the callback being triggered in some sort of bad state causing a Unity-level exception of some kind?).
Thanks!
--Patrick