Опубликуйте код, который я использую, чтобы получить сообщение и отобразить уведомление от firebase. Я получаю уведомление с правильным текстом и заголовком, но это уведомление не работает. Даже я устанавливаю звук по умолчанию или настраиваемый звук. Как воспроизвести правильный звук?Android Notification Builder не воспроизводит пользовательский звук
общественного класса NotificationMessagingService расширяет FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("sb.fbv", "NotificationMessaginService.onmessageReceived");
String title = remoteMessage.getNotification().getTitle();
String subText = remoteMessage.getNotification().getBody();
String message = remoteMessage.getData().get("subtext");
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder nb = new NotificationCompat.Builder(this);
nb.setContentTitle(title);
nb.setSubText(message);
nb.setContentText(subText);
nb.setSmallIcon(R.drawable.notificavedelago);
nb.setAutoCancel(true);
nb.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
nb.setLights(Color.BLUE, 3000, 3000);
//SOUND DEFAULT
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
nb.setSound(alarmSound);
//CUSTOM SOUND
//Uri customSound= Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sound);
//nb.setSound(customSound);
nb.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, nb.build());
}
}
Чтобы настроить использование пользовательских уведомлений: nb.setDefaults (Notification.DEFAULT_SOUND); Для получения специального уведомления я не могу вам помочь –