package br.com.alura.agenda.firebase;

import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.Map;

public class AgendaMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);

        Map<String, String> mensagem = remoteMessage.getData();
        Log.i("mensagem recebida", String.valueOf(mensagem));
    }
}

@@ -58,16 +58,68 @@
 l.Log;%0A%0A
+import com.fasterxml.jackson.databind.ObjectMapper;%0A
 import c
@@ -229,28 +229,140 @@
 ge;%0A
-import java.util.Map
+%0Aimport java.io.IOException;%0Aimport java.util.Map;%0Aimport br.com.alura.agenda.dao.AlunoDAO;%0Aimport br.com.alura.agenda.dto.AlunoSync
 ;%0A%0Ap
@@ -685,16 +685,678 @@
 sagem));
+%0A%0A        converteParaAluno(mensagem);%0A    %7D%0A%0A    private void converteParaAluno(Map%3CString, String%3E mensagem) %7B%0A        String chaveDeAcesso = %22alunoSync%22;%0A        if (mensagem.containsKey(chaveDeAcesso)) %7B%0A            String json = mensagem.get(chaveDeAcesso);%0A            ObjectMapper mapper = new ObjectMapper();%0A            try %7B%0A                AlunoSync alunoSync = mapper.readValue(json, AlunoSync.class);%0A                AlunoDAO alunoDAO = new AlunoDAO(this);%0A                alunoDAO.sincroniza(alunoSync.getAlunos());%0A                alunoDAO.close();%0A            %7D catch (IOException e) %7B%0A                e.printStackTrace();%0A            %7D%0A        %7D
 %0A    %7D%0A%7D

Convert info send by server into student objects