public Notification Render(Context context, string channelId) { var builder = new NotificationCompat.Builder(context, channelId) .SetContentTitle(Title) .SetContentText(Body) .SetVisibility((int)NotificationVisibility.Public) .SetCategory(Notification.CategoryMessage) .SetContentIntent(CreateLaunchIntent(context)); builder.SetWhen(NotifyTime.ToUnixTime()); if (Icon?.Name.HasValue() == true) { builder.SetSmallIcon(Icon.ConvertToId(context)); } if (OS.IsAtLeast(BuildVersionCodes.Lollipop) && TransparentIcon?.Name.HasValue() == true) { builder.SetSmallIcon(TransparentIcon.ConvertToId(context)); builder.SetColor(Color.Parse(TransparentIconColor.Or("transparent")).Render().ToArgb()); } if (PlaySound) { builder.SetSound(LocalNotification.GetSoundUri()); } return(builder.Build()); }
static AndroidLocalNotification CreateNotification(string title, string body, bool playSound, int id, Dictionary <string, string> parameters) { return(new AndroidLocalNotification { Title = title, Body = body, PlaySound = playSound, Id = id, IntentId = GetUniqueId, Icon = Icon, TransparentIcon = TransparentIcon, TransparentIconColor = TransparentIconColor.ToStringOrEmpty().Or("transparent"), NotifyTime = DateTime.Now, Parameters = parameters }); }