public override Task Send(Notification notification) { if (notification.Id == null) { Services.Repository.CurrentScheduleId++; notification.Id = Services.Repository.CurrentScheduleId; } if (notification.IsScheduled) { var triggerMs = this.GetEpochMills(notification.SendTime); var pending = notification.ToPendingIntent(notification.Id.Value); this.alarmManager.Set( AlarmType.RtcWakeup, Convert.ToInt64(triggerMs), pending ); Services.Repository.Insert(notification); } else { var launchIntent = Application.Context.PackageManager.GetLaunchIntentForPackage(Application.Context.PackageName); launchIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); foreach (var pair in notification.Metadata) { launchIntent.PutExtra(pair.Key, pair.Value); } var builder = new Android.App.Notification.Builder(Application.Context) .SetAutoCancel(true) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) .SetContentTitle(notification.Title) .SetContentText(notification.Message) .SetSmallIcon(AppIconResourceId) .SetPriority(priority.HasValue ? priority.Value : NotificationCompat.PriorityMax) .SetContentIntent(TaskStackBuilder .Create(Application.Context) .AddNextIntent(launchIntent) .GetPendingIntent(notification.Id.Value, PendingIntentFlags.OneShot) ); if (notification.Vibrate) { builder.SetVibrate(new long[] { 500, 500 }); } if (notification.Sound != null) { if (!notification.Sound.Contains("://")) { notification.Sound = $"{ContentResolver.SchemeAndroidResource}://{Application.Context.PackageName}/raw/{notification.Sound}"; } var uri = Android.Net.Uri.Parse(notification.Sound); builder.SetSound(uri); } var not = builder.Build(); NotificationManagerCompat .From(Application.Context) .Notify(notification.Id.Value, not); } return(Task.CompletedTask); }