I do want to create a plugin which does implement something like a notification-service.
So what I'm doing at the moment is something like this:
var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity;
var builder = new NotificationCompat.Builder(activity.ApplicationContext)
.SetContentTitle(title)
.SetSmallIcon(Resource.Drawable.Icon)
.SetContentText(message);
var notificationManager = (NotificationManager)activity.ApplicationContext.GetSystemService(Context.NotificationService);
notificationManager.Notify(0, builder.Build());
This works fine and does show the notification as it should show. Next step is, that I want to navigate from the notification to my activity. Which means in MvvmCross I do want to navigate to my ViewModel.
But how do I now pack the ShowViewModel<...>()-Command into this notification? Is this even possible?
On native android I would create a PendingIntent which does point to my Activity I want to show.
Any idea? Hint? Tip? :-)
The default MvvmCross presenter on Android uses
Intent
s for navigation. These are generated by the methodIntent GetIntentFor(MvxViewModelRequest request)
in theIMvxAndroidViewModelRequestTranslator
interface.By default this is implemented within: MvxAndroidViewsContainer.cs#L117
If you need to generate
Intent
s for other purposes (e.g. in order to then go on and generatePendingIntent
s) then you canResolve
and call this interface yourself.For further information on generating
MvxViewModelRequest
objects, see also the overloadedShowViewModel
methods in MvxNavigatingObject.cs