Работало ли решение с тобой? @MuahmmadTayyib

равляю push-уведомление от Google Firebase для моего приложения для Android с целью Android 5.0:

Мой код push-уведомления:

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    String badge = "0";
    Uri uri = Uri.parse(
            getString(R.string.app_host_name)
    );

    Map<String, String> data = remoteMessage.getData();
    if (data.size() > 0) {
        try {
            uri = Uri.parse(
                    data.get("link")
            );

            badge = data.get("badge");
        } catch (NullPointerException e) {
            //
        }
    }

    if (remoteMessage.getNotification() != null) {
        RemoteMessage.Notification notification = remoteMessage.getNotification();
        sendNotification(notification.getTitle(), notification.getBody(), uri.toString(), badge);
    }
}



private void sendNotification(String title, String body, String url, String badge) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    if (Patterns.WEB_URL.matcher(url).matches()) {
        intent.putExtra("link", url);
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(
            this,
            0,
            intent,
            PendingIntent.FLAG_UPDATE_CURRENT
    );

    Resources resources = getApplicationContext().getResources();

    NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(this, "default")
                    .setColor(
                            resources.getColor(R.color.colorPrimaryDark)
                    )
                    .setSmallIcon(
                            R.drawable.ic_stat_icon
                    )
                    .setContentTitle(title)
                    .setContentText(body)
                    .setAutoCancel(true)
                    .setNumber(Integer.parseInt(badge))
                    .setLargeIcon(
                            BitmapFactory.decodeResource(
                                    resources,
                                    R.mipmap.ic_launcher
                            )
                    )
                    .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    if (Build.VERSION.SDK_INT >= 26) {
        NotificationChannel notificationChannel = new NotificationChannel(
                "default",
                "Main notification channel",
                NotificationManager.IMPORTANCE_HIGH
        );

        notificationManager.createNotificationChannel(
                notificationChannel
        );
    }

    notificationManager.notify(
            1,
            notificationBuilder.build()
    );
}

И все супер идеально, когда приложение активно / открыто / не в фоновом режиме, но когда это не так, уведомления не сгруппированы, не отображается номер и вообще не реагирует на все эти настройки, что я смог изменить только маленький значок и цвет круга через настройки манифеста

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_stat_icon" />
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorPrimaryDark" />

но почему? Это похоже на то, когда приложение в фоновых уведомлениях не использует настройки из кода Activity, а использует только какой-то тип по умолчанию из AndroidManifest.

Ответы на вопрос(1)

Ваш ответ на вопрос