Que tal bueno es algo extraño pero no puedo mostrar mi notificationCompat.. ahora tengo el mensaje tranquilamente lo veo ya que lo muestro en el LOG, pero es algo extraño y no he encontrado la manera para poder mostrarlo. Estoy usando Firebase. La clase dónde se encuentra mi servicio es
public class MyFcmListenerService extends com.google.firebase.messaging.FirebaseMessagingService {
public static final String TAG = MyFcmListenerService.class.getSimpleName();
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG,"HECHO");
Log.d(TAG,remoteMessage.getData().get("message"));
if (Test.getTest(1).isEstado_token()) {
Log.d(TAG,"bolean1"+String.valueOf(Test.getTest(1).isEstado_token()));
mostrarMensaje(remoteMessage.getData().get("message"));
}
}
private void mostrarMensaje(String mensaje) {
SharedPreferences preferences = getSharedPreferences(Constantes.PREFERENCIA_PARA_PREGUNTAS, Context.MODE_PRIVATE);
int pre_token_count = preferences.getInt(Constantes.KEY_IDENTIFICADOR, 0);
Intent i = new Intent(this, PrincipalActivity.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("TEST")
.setContentText(mensaje)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setVibrate(new long[]{2000, 2000, 2000, 2000, 2000});
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(pre_token_count, builder.build());
SharedPreferences.Editor editor = preferences.edit();
pre_token_count++;
editor.putInt(Constantes.KEY_IDENTIFICADOR, pre_token_count);
editor.commit();
}
}