Вчера Google представил в Google I/O новую систему уведомлений на основе новой Firebase. Я попробовал эту новую FCM (Firebase Cloud Messaging) с примером в Github.Значок уведомлений с новой системой обмена облаками Firebase
значок уведомления всегда ic_launcher несмотря я объявил конкретную вытяжку
Почему? Здесь ниже официального кода для обработки сообщения
public class AppFirebaseMessagingService extends FirebaseMessagingService {
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
sendNotification(remoteMessage);
}
// [END receive_message]
/**
* Create and show a simple notification containing the received FCM message.
*
* @param remoteMessage FCM RemoteMessage received.
*/
private void sendNotification(RemoteMessage remoteMessage) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
// this is a my insertion looking for a solution
int icon = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.myicon: R.mipmap.myicon;
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(icon)
.setContentTitle(remoteMessage.getFrom())
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
firebase не имеет никакого отношения к тому, как вы создаете уведомление, пожалуйста, предоставьте изображение относительно того, что вы видите – tyczj
точным. этот код поступает прямо из метода Firebase, а метод sendNotification() точно такой же для любого уведомления. Этот код отлично работает с GCM, но с FCM no. он всегда остается ic_launcher, используя новый веб-интерфейс для отправки сообщений – marco
вы устанавливаете маленький значок, но не большой значок, если вы не отправляете push с тегом уведомлений в полезной нагрузке push, это не имеет никакого отношения к FCM – tyczj