Fórum Bom dia galera preciso de uma ajuda de vcs #579455
28/03/2017
0
Bom dia galera, fiz um protótipo de notificação esta funcionando tudo certinho, o que eu não sei fazer é como é mostrar o TEXTO e TITULO da notificação...
Alguém pode me ajuda, como fazer isso.. código abaixo:
Queria mostrar esse TITLE e o MESSAGE, quando a pessoa clicar na notificação ele armazena e ela abre e consegue le o que está escrito..
vlw galera
Alguém pode me ajuda, como fazer isso.. código abaixo:
public class FcmMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
String title = remoteMessage.getNotification().getTitle();
String message = remoteMessage.getNotification().getBody();
String click_action = remoteMessage.getNotification().getClickAction();
Intent intent = new Intent(click_action);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle(title);
notificationBuilder.setContentText(message);
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);
notificationBuilder.setAutoCancel(true);
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificationBuilder.build());
}
}
Queria mostrar esse TITLE e o MESSAGE, quando a pessoa clicar na notificação ele armazena e ela abre e consegue le o que está escrito..
vlw galera
Fernando
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)