How to redirect user when app is opened from notification

I don’t know this is a normal thing or not to ask, but I require your guys help on this topic.

In my app I want my user to tap on a notification and open a certain scene using the data of that FCM notification. I’ve already done this thing in Android but I’m unable to figure this out for iOS.

Here is the code for my android notification redirection:

 #if UNITY_ANDROID
     if (hasFocus)
     {
         AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
         AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
         AndroidJavaObject intent = currentActivity.Call<AndroidJavaObject>("getIntent");
         string onClickScreen = intent.Call<string>("getStringExtra", "onClickScreen");
         if (onClickScreen != null && onClickScreen.Trim().Length > 0)
         {
             redirectToAppropriateScreen(intent, onClickScreen);
         }
         intent.Call("removeExtra", "onClickScreen");
     }
#endif

All local and push notifications can be read via NotificationServices. And they should have userInfo dictionaries that have all extra info
https://docs.unity3d.com/ScriptReference/iOS.NotificationServices.html

1 Like

hey @kaarloew
Thanks for the help. Sorry that I didn’t thank you.

But now I’m in a different problem NotificationServices works perfectly fine if the Application is running in background. but when the Application is closed and not running in the background, I get 0 as remoteNotificationCount. please help.

Hi @Ankit_JeGames
Did you find a solution for that?