This can be done in MvvmCross 5+, but it is not as clean as before.
First, you want to specify the SingleTop startup mode for your activity:
[Activity(LaunchMode = LaunchMode.SingleTop, ...)] public class MainActivity : MvxAppCompatActivity
Create a PendingIntent notification as follows:
var intent = new Intent(Context, typeof(MainActivity)); intent.AddFlags(ActivityFlags.SingleTop);
Now there are two ways to handle this intention from MainActivity, while at the same time allowing you to use the MvvmCross navigation service:
If the application was not launched while clicking on the notification, OnCreate will be.
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (bundle == null && Intent.HasExtra("from_notification")) {
If the application was launched while clicking on the notification, OnNewIntent will be.
protected override void OnNewIntent(Intent intent) { base.OnNewIntent(intent); if (intent.HasExtra("from_notification")) {
source share