Firebase device to device messaging using Retrofit, how do i get message id?

前端 未结 1 1739
暗喜
暗喜 2020-12-17 07:58

I use Retrofit for sending device to device message without php script and curl command and everything work fine. I need to save sent message ID. How can i get after success

相关标签:
1条回答
  • 2020-12-17 08:49

    I have extended my Message POJO

    public class Message {
    String to;
    NotifyData notification;
    String message_id;
    
    public Message(String to, NotifyData notification, String message_id) {
        this.to = to;
        this.notification = notification;
        this.message_id = message_id;
        }
    
    public String getMessage_id() {
    
        return message_id;
        }
    
    }
    

    Firebase get message_id in Response after sending FCM message

    Call<Message> call2 = firebaseAPI.sendMessage(new Message(to, notifydata, ""));
        call2.enqueue(new Callback<Message>() {
            @Override
            public void onResponse(Call<Message> call, Response<Message> response) {
    
                Log.d("Response ", "onResponse");
                //t1.setText("Notification sent");
                Message message = response.body();
                Log.d("message", message.getMessage_id());
    
            }
    
            @Override
            public void onFailure(Call<Message> call, Throwable t) {
                Log.d("Response ", "onFailure");
                //t1.setText("Notification failure");
            }
        });
    
    0 讨论(0)
提交回复
热议问题