public static void SendDumbNotification() { NotificationManager notificationManager = (NotificationManager)Application.Context.GetSystemService("notification"); Notification.Builder builder; if (Build.VERSION.SdkInt < BuildVersionCodes.NMr1) { #pragma warning disable CS0618 // 'Notification.Builder.SetPriority(int)' está obsoleto: 'deprecated' builder = new Notification.Builder(Application.Context); builder.SetPriority(Convert.ToInt32(NotificationPriority.Max)); #pragma warning restore CS0618 // 'Notification.Builder.SetPriority(int)' está obsoleto: 'deprecated' } else { NotificationChannel notificationChannel = new NotificationChannel("livedisplaynotificationchannel", "LiveDisplay", NotificationImportance.Max); notificationManager.CreateNotificationChannel(notificationChannel); builder = new Notification.Builder(Application.Context, "livedisplaynotificationchannel"); } RemoteInput remoteInput = new RemoteInput.Builder("test1").SetLabel("This is the place where you write").Build(); Intent intent = new Intent(Application.Context, Java.Lang.Class.FromType(typeof(MainActivity))); PendingIntent pendingIntent = PendingIntent.GetActivity(Application.Context, 35, intent, PendingIntentFlags.UpdateCurrent); Notification.Action.Builder action = new Notification.Action.Builder(Resource.Drawable.ic_stat_default_appicon, "Answer", pendingIntent).AddRemoteInput(remoteInput); builder.SetStyle(new Notification.MessagingStyle("Su madre").AddMessage(new Notification.MessagingStyle.Message("hi", -1, "user1")) .AddMessage(new Notification.MessagingStyle.Message("WhatsUp", 0, "user2")) .AddMessage(new Notification.MessagingStyle.Message("How bout lunch?", 1, "user1"))); #pragma warning restore builder.SetContentTitle(""); builder.SetContentText(""); builder.SetAutoCancel(true); builder.AddAction(action.Build()); builder.SetSmallIcon(Resource.Drawable.ic_stat_default_appicon); notificationManager.Notify(2, builder.Build()); }
public void PostNotification(int notifid, string title, string text, bool autoCancellable, NotificationImportance notificationImportance) { NotificationChannel notificationChannel = new NotificationChannel("livedisplaynotificationchannel", "LiveDisplay", notificationImportance); notificationManager.CreateNotificationChannel(notificationChannel); Notification.Builder builder = new Notification.Builder(Application.Context, "livedisplaynotificationchannel"); builder.SetContentTitle(title); builder.SetContentText(text); builder.SetAutoCancel(autoCancellable); builder.SetSmallIcon(Resource.Drawable.ic_stat_default_appicon); builder.SetAutoCancel(true); RemoteInput remoteInput = new RemoteInput.Builder("test1").SetLabel("This is the place where you write").Build(); Intent intent = new Intent(Application.Context, Java.Lang.Class.FromType(typeof(SettingsActivity))); PendingIntent pendingIntent = PendingIntent.GetActivity(Application.Context, 35, intent, PendingIntentFlags.UpdateCurrent); Notification.Action.Builder action = new Notification.Action.Builder(Resource.Drawable.ic_stat_default_appicon, "Answer", pendingIntent).AddRemoteInput(remoteInput); builder.AddAction(action.Build()); notificationManager.Notify(notifid, builder.Build()); }