title: Xamarin Android OnNewIntent Not Called by Closed App
body: <p><strong>What is Working</strong></p>
  
  <p>I have implemented push notification for the Android side of our Xamarin Forms app using the following Xamarin guide:</p>
  
  <p><a href="https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-gcm/" rel="noreferrer">https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-gcm/</a></p>
  
  <p>This has worked great and we correctly and OnNewIntent is called when the application is running and in the background. We then call our method to process the push notification's intent and all is well.</p>
  
  <pre><code>protected override void OnNewIntent(Intent intent)
  {
      base.OnNewIntent(intent);
      GoogleListenerService.ReceivedRemoteNotification(intent);
  }
  </code></pre>
  
  <p><strong>What is the Problem</strong></p>
  
  <p>If we close the application, trigger a push notification, and click on the push notification, the application does not appear to call OnNewIntent and instead appears to start the application exactly as it would if we just clicked the app icon (calling OnCreate).</p>
  
  <p><strong>What has been tried</strong></p>
  
  <p>The main workarounds I have tried implementing are outlined by:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/30708462/android-onnewintent-not-called">Android OnNewIntent not called</a></li>
  </ol>
  
  <p>Xamarin only has a GetIntent method that requires an string URL input, and using the following results in null data.</p>
  
  <pre><code>Intent intent = new Intent(this, typeof(MainActivity));
  Bundle data = intent.Extras;
  </code></pre>
  
  <ol start="2">
  <li><a href="https://stackoverflow.com/questions/23446120/onnewintent-is-not-called">onNewIntent is not called</a></li>
  </ol>
  
  <p>In the second post, all changes to LaunchMode = SingleTop in our intent service, our MainActivity.cs file, and in our manifest file have resulted in no changes in behavior.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Push notifications are always received and OnMessageReceived is always getting called, whether the application be in the background, or closed altogether. Moreover, OnNewIntent receives the pending intent when the application is in the background, just not when it is closed.</p>
  
  <pre><code>this.Intent.Extras;
  </code></pre>
  
  <p>Always appears to evaluate to null (currently located in the OnResume method).</p>