вот мой код
val intent = Intent("com.sbs16.ensofia.OPEN")
//intent.putExtra(MSDConstants.ACTIVITY_NOTIFICATION_TYPE, mType)
//intent.putExtra(MSDConstants.ACTIVITY_NOTIFICATION_ID, mId)
//intent.putExtra(MSDConstants.ACTIVITY_NOTIFICATION_URL, mUrl)
val pendingIntent = PendingIntent.getBroadcast(applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val notificationBuilder =
NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
.setContentTitle(getString(R.string.app_name))
.setContentText(body)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(BitmapFactory.decodeResource(resources, R.drawable.icon_notifications))
.setColor(resources.getColor(R.color.red))
.setLights(Color.RED, 1000, 300)
.setDefaults(Notification.DEFAULT_VIBRATE)
.setSmallIcon(R.drawable.icon_notifications)
var notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
val importance = NotificationManager.IMPORTANCE_DEFAULT
val id = getString(R.string.notification_channel_id)
val name = getString(R.string.notification_channel_name)
val description = getString(R.string.notification_channel_description)
val channel = NotificationChannel(id, name, importance)
channel.description = description
channel.enableLights(true);
channel.lightColor = Color.RED;
channel.enableVibration(true);
notificationManager.createNotificationChannel(channel)
}
notificationManager.notify(0, notificationBuilder.build())