how do I get the key brings me the notification

1

This is my class that receives the notification as I can get back the key that it brings me to then save them automatically when the notification arrives

  @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        //en este metodo se recibe la notificacion
        String from = remoteMessage.getFrom();
        String a= remoteMessage.getCollapseKey();

        Log.e("DE: ", from);
        if (remoteMessage.getNotification().getBody() != null) {
            Log.e("CUERPO", remoteMessage.getNotification().getBody());

            String p=remoteMessage.getNotification().getTitleLocalizationKey();
            System.out.println("prueba_notificaion"+remoteMessage.getNotification().getTitleLocalizationKey());

        showNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
    }
    if (remoteMessage.getData().size() > 0) {
        Log.e("DATA", "DATA" + remoteMessage.getData());
        String data= String.valueOf(remoteMessage.getData());
        System.out.println("data_data:"+data);

        }
    
asked by natalia 04.04.2017 в 23:33
source

1 answer

0

The push message data is sent as "data" in the RemoteMessage object , to access it simply call remoteMessage.getData() and that returns a map with the information.

    
answered by 30.05.2017 в 17:03