What is Working
I have implemented push notification for the Android side of our Xamarin Forms app using the following Xamarin guide:
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.
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
GoogleListenerService.ReceivedRemoteNotification(intent);
}
What is the Problem
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).
What has been tried
The main workarounds I have tried implementing are outlined by:
Xamarin only has a GetIntent method that requires an string URL input, and using the following results in null data.
Intent intent = new Intent(this, typeof(MainActivity));
Bundle data = intent.Extras;
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.
EDIT
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.
this.Intent.Extras;
Always appears to evaluate to null (currently located in the OnResume method).