- Home /
 
               Question by 
               elfasito · Jan 27, 2021 at 01:58 PM · 
                androidscripting problemnotificationsintent  
              
 
              how to open app from notification intent
Hello people. I want to open the app when the user clicks on a notification and after opening it, open a specific scene. this is almost working. I have only a problem with my script: after open from the intent (ok), and later If I pause/minimize the app again and resume in the main menu (where the script is running), the function run again, so keeps loading the scene again every time I resume from pause/minimize the app. I cant figure out how can solve it in my code. can give me some guidance?.
 public static FCMSceneController instance;
     void OnApplicationPause(bool appPaused)
         {
             if (!appPaused)
             {
                 //Returning to Application
                 Debug.Log("Application Resumed");
                 StartCoroutine(LoadSceneFromFCM());
             }
             else
             {
                 //Leaving Application
                 Debug.Log("Application Paused");
             }
         }
     
         IEnumerator LoadSceneFromFCM()
         {
             AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
             AndroidJavaObject curActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
             AndroidJavaObject curIntent = curActivity.Call<AndroidJavaObject>("getIntent");
     
             string sceneToLoad = curIntent.Call<string>("getStringExtra", "sceneToOpen");
     
             Scene curScene = SceneManager.GetActiveScene();
     
             if (!string.IsNullOrEmpty(sceneToLoad) && sceneToLoad != curScene.name)
             {
                 // If the current scene is different than the intended scene to load,
                 // load the intended scene. This is to avoid reloading an already acive
                 // scene.
                 Debug.Log("Loading Scene: " + sceneToLoad);
                 Handheld.SetActivityIndicatorStyle(AndroidActivityIndicatorStyle.Large);
                 Handheld.StartActivityIndicator();
                 yield return new WaitForSeconds(0f);
     
                 SceneManager.LoadScene(sceneToLoad);
             }
         }
PD: android platform
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                