I am trying to make a Unity app in which firebase is sending notification to both android and iOS. but I want to open a specific scene when someone click on the notification. I don't have any idea how to do this.
I think you are looking for something like a dynamic link there is another firebase service for that called dynamic links here- https://firebase.google.com/docs/dynamic-links/unity/receive or deep links in unity here - https://docs.unity3d.com/Manual/enabling-deep-linking.html
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
var intent = currentActivity.Call<AndroidJavaObject>("getIntent");
var extras = GetExtras(intent);
var sceneToLoad = GetProperty(extras, "<key to load in string>");
var currentScene = SceneManager.GetActiveScene();
GetExtras() function
private static AndroidJavaObject GetExtras(AndroidJavaObject intent)
{
AndroidJavaObject extras = null;
try
{
extras = intent.Call<AndroidJavaObject>("getExtras");
}
catch (Exception e)
{
Debug.LogError("firebaseScript.GetExtras()->" + e.Message);
}
return extras;
}
GetProperty function
private static string GetProperty(AndroidJavaObject extras, string name)
{
var s = string.Empty;
try
{
s = extras.Call<string>("getString", name);
}
catch (Exception e)
{
Debug.LogError("firebaseScript.GetProperty() throws ->" + e.Message);
}
return s;
}