I'm developing an Xamarin.Forms app and I need to handle the Push Notifications on the Android app. I need to have a button on the notification that the user is seeing and he can click on it. Here is the notification that I'm building according to Azure MSDN documentations:
void createNotification(string title, string desc)
{
//Create notification
var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
//Create an intent to show ui
var uiIntent = new Intent(this, typeof(MainActivity));
//Use Notification Builder
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
//Create the notification
//we use the pending intent, passing our ui intent over which will get called
//when the notification is tapped.
var notification = builder.SetContentIntent(PendingIntent.GetActivity(this, 0, uiIntent, 0))
.SetSmallIcon(Resource.Drawable.ic_stat_ic_notification)
.SetTicker(title)
.SetContentTitle(title)
.SetContentText(desc)
//.AddAction(new NotificationCompat.Action())
//Set the notification sound
.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
//Auto cancel will remove the notification once the user touches it
.SetAutoCancel(true).Build();
//Show the notification
notificationManager.Notify(1, notification);
}
How do I add a button and how to trigger it so when it has been pressed how do I invoke a method?
Thanks.