Hi I am using simple firebase notification console to send the push notifications, but when my app is close, I can only get the default style of notification. Can someone show how to make it work with custom style of notifications within the app is closed. This is my onMessageReceived
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(this.getClass().getSimpleName(), "onMessageReceived");
String message = remoteMessage.getData().get("image");
Log.d(this.getClass().getSimpleName(), "From: " + remoteMessage.getFrom());
//Check if the message contains data
if(remoteMessage.getData().size()>0){
Log.d(this.getClass().getSimpleName(), "Message data: " + remoteMessage.getData());
}
//Check if the message contains notification
if(remoteMessage.getNotification() != null){
Log.dthis.getClass().getSimpleName(), "Message body: "+remoteMessage.getNotification().getBody());
sendNotification(remoteMessage.getNotification().getBody());
}
}
and this is my sendnotification
private void sendNotification(String body) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingintent = PendingIntent.getActivity(this, 0/*Request code*/, intent, PendingIntent.FLAG_ONE_SHOT);
//set sound of notification
Uri notificationSoound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notifiBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Firebase Cloud Messaging")
.setContentText(body)
.setAutoCancel(true)
.setSound(notificationSoound)
.setContentIntent(pendingintent);
NotificationManager noticationmessanger = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
noticationmessanger.notify(0/*Id of notification*/,notifiBuilder.build());
}