Sergey Penkin
канал то я создаю
public int ScheduleNotification(string title, string message)
{
if (!channelInitialized)
{
CreateNotificationChannel();
}
messageId++;
Intent intent = new Intent(AndroidApp.Context, typeof(MainActivity));
intent.PutExtra(TitleKey, title);
intent.PutExtra(MessageKey, message);
PendingIntent pendingIntent = PendingIntent.GetActivity(AndroidApp.Context, pendingIntentId, intent, PendingIntentFlags.OneShot);
//NotificationCompat.BigTextStyle textStyle = new NotificationCompat.BigTextStyle();
//textStyle.BigText(message);
//textStyle.SetSummaryText("З повагою, Ваша служба таксі!");
NotificationCompat.Builder builder = new NotificationCompat.Builder(AndroidApp.Context, channelId)
.SetContentIntent(pendingIntent)
.SetContentTitle(title)
.SetContentText(message)
.SetLargeIcon(BitmapFactory.DecodeResource(AndroidApp.Context.Resources, Resource.Drawable.logo))
.SetSmallIcon(Resource.Drawable.logo)
.SetPriority((int)NotificationPriority.High)
.SetAutoCancel(true)
// .SetStyle(textStyle)
.SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate);
var notification = builder.Build();
manager.Notify(messageId, notification);
return messageId;
}
void CreateNotificationChannel()
{
manager = (NotificationManager)AndroidApp.Context.GetSystemService(AndroidApp.NotificationService);
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
{
var channelNameJava = new Java.Lang.String(channelName);
var channel = new NotificationChannel(channelId, channelNameJava, NotificationImportance.High);
manager.CreateNotificationChannel(channel);
}
channelInitialized = true;
}
}