Я пытаюсь отправить push-уведомление с консоли Firebase, в настоящее время я могу отправить сообщение с моей консоли Firebase на мое виртуальное устройство, но если сообщение длинное, оно не будет полностью отображаться на панели уведомлений.Как добавить уведомление об «большом тексте» или «в почтовом ящике» для этого проекта Firebase android?
Это код Firebasemessagingservice:
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import com.google.firebase.messaging.RemoteMessage;
/**
* Created by filipp on 5/23/2016.
*/
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService{
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
showNotification(remoteMessage.getData().get("message"));
}
private void showNotification(String message) {
Intent i = new Intent(this,MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("Elit")
.setContentText(message)
//.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(0,builder.build());
}
}
Спасибо Adib за подробный ответ, у меня уже есть сервер PHP бэкэнд, но всякий раз, когда я пытаюсь отправить длинное уведомление от сервера не будет отображаться полностью , мой вопрос: могу ли я только отредактировать последнюю часть кода, чтобы я мог отправлять длинные уведомления с моего сервера либо с помощью inboxStyle, либо в bigtextstyle.
private void showNotification(String message) {
Intent i = new Intent(this,MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("Elit")
.setContentText(message)
//.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(0,builder.build());
}
Каков ваш вопрос? – Nico
Как я могу изменить свой код, поэтому, когда я отправляю уведомление на виртуальное устройство, я могу расширить уведомление. – kazamama