In the example below, the mvvmcross-based android app is opened from a Notification/PendingIntent. The PendingIntent's target is actually an MvxFragment.
When the Notification is tapped, nothing happens in the app, the associated ViewModel's constructor isn't fired and no MVX events are logged. If the PendingIntent's target is changed to being an Activity derivative, everything works correctly.
What then is the correct 'MVX' way to handle scenarios like this, ie Notification's target is a fragment.
Sample broken code:
var appContext = Mvx.Resolve<IMvxAndroidGlobals>().ApplicationContext;
// SomeViewModel --- derives MvxViewModel
// SomeViewModelView --- front end MvxFragment for SomeViewModel
var request = new MvxViewModelRequest<SomeViewModel>(
new MvxBundle(SomeViewModel.CreateParameters("a_parameter_value").ToSimplePropertyDictionary()),
null,
null);
var translator = Mvx.Resolve<IMvxAndroidViewModelRequestTranslator>();
var uiIntent = translator.GetIntentFor(request);
var pendingUiIntent = PendingIntent.GetActivity(appContext, 0, uiIntent, 0);
var notificationManager = (NotificationManager)appContext.GetSystemService(Context.NotificationService);
var notificationBuilder = new NotificationCompat.Builder(context)
.SetAutoCancel(true)
...
.SetContentIntent(onSelectedIntent);
// show the notification
notificationManager.Notify(id, notificationBuilder.Build());
// after user taps notification, nothing happens