Я использую эту функцию сейчас и отлично работает
private void CreateNotificationMessage(Context ctx,String Title,String Msg){
int id=15;
Intent intent= new Intent(ctx, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, intent, 0);
Notification.Builder b = new Notification.Builder(ctx);
NotificationChannel mChannel = null;
b.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_luncher)
.setContentTitle(Title)
.setTicker(Title)
.setContentText(Msg)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentIntent(contentIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mChannel = new NotificationChannel("cid", "name",NotificationManager.IMPORTANCE_HIGH);
b.setChannelId("cid");
mChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
.build());
}
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationManager.createNotificationChannel(mChannel);
}
notificationManager.notify(id, b.build());
}