1

Cuando recibo una notificación push con Firebase al dar click sobre ella quiero mandar sus datos a otro activity, intente con putextra pero no funciona, les adjunto mi codigo.

Clase donde recibo las notificaciones:

public void onMessageReceived(RemoteMessage remoteMessage) {
    Intent intent = new Intent(MyFirebaseMessagingService.this, Splash.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("Mensaje", remoteMessage.getNotification().getBody());
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder.setContentTitle("Sección 15");
    notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
    notificationBuilder.setContentIntent(pendingIntent);
    notificationBuilder.setAutoCancel(true);
    notificationBuilder.setSmallIcon(R.drawable.logo);
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0,notificationBuilder.build());
}

Clase donde quiero recuperar la información de la notificación:

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    if (getIntent().getExtras() != null) {
        String title = getIntent().getStringExtra("Mensaje");

        TextView txtCambiado = (TextView)findViewById(R.id.textView10);
        txtCambiado.setText(title);
    }else{
        new Handler().postDelayed(new Runnable(){
            public void run(){
                // Cuando pasen los 3 segundos, pasamos a la actividad principal de la aplicación
                Intent intent = new Intent(Splash.this, Inicio.class);
                startActivity(intent);
                overridePendingTransition(R.anim.left_in, R.anim.left_out);
                finish();
            };
        }, DURACION_SPLASH);
    }
3
  • Estas seguro que tu mensaje remoto contiene una notificación? hiciste una depuración? Se te muestra la notificación que estas creando? el 22 mar. 2017 a las 22:54
  • De echo manda mucha información pero son como datos que no usas etc... mira te mando un ejemplo: el 22 mar. 2017 a las 23:02
  • una consulta, estas enviando la notificación con "data" adicional? en caso de que no se asi es muy posible que la notificación que estes viendo sea la creada por defecto por Firebase.
    – jirungaray
    el 30 may. 2017 a las 15:05

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.