title: Firebase device to device messaging using Retrofit, how do i get message id?
body: <p>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 sending message ID for sent message. My code.
  Sending activity</p>
  
  <pre><code>public void onClick(View view) {
  
  HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
  logging.setLevel(HttpLoggingInterceptor.Level.BODY);
  
  OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
  httpClient.addInterceptor(new Interceptor() {
      @Override
      public okhttp3.Response intercept(Chain chain) throws IOException {
          Request original = chain.request();
  
          // Request customization: add request headers
          Request.Builder requestBuilder = original.newBuilder()
                  .header("Authorization", "key=legacy server key from FB console"); // &lt;-- this is the important line
          Request request = requestBuilder.build();
          return chain.proceed(request);
      }
  });
  
  httpClient.addInterceptor(logging);
  OkHttpClient client = httpClient.build();
  
  Retrofit retrofit = new Retrofit.Builder()
          .baseUrl("https://fcm.googleapis.com")//url of FCM message server
          .client(client)
          .addConverterFactory(GsonConverterFactory.create())//use for convert JSON file into object
          .build();
  
  // prepare call in Retrofit 2.0
  FirebaseAPI firebaseAPI = retrofit.create(FirebaseAPI.class);
  
  //for messaging server
  NotifyData notifydata = new NotifyData("Notification title","Notification body");
  
  Call&lt;Message&gt; call2 = firebaseAPI.sendMessage(new Message("...... device token ....", notifydata));
  
  call2.enqueue(new Callback&lt;Message&gt;() {
      @Override
      public void onResponse(Call&lt;Message&gt; call, Response&lt;Message&gt; response) {
  
          Log.d("Response ", "onResponse");
          t1.setText("Notification sent");
  
      }
  
      @Override
      public void onFailure(Call&lt;Message&gt; call, Throwable t) {
          Log.d("Response ", "onFailure");
          t1.setText("Notification failure");
      }
  });
  }
  </code></pre>
  
  <p>POJOs</p>
  
  <pre><code>public class Message {
  String to;
  NotifyData notification;
  
  public Message(String to, NotifyData notification) {
      this.to = to;
      this.notification = notification;
  }
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public class NotifyData {
  String title;
  String body;
  
  public NotifyData(String title, String body ) {
  
      this.title = title;
      this.body = body;
  }
  
  }
  </code></pre>
  
  <p>and FirebaseAPI </p>
  
  <pre><code>public interface FirebaseAPI {
  
  @POST("/fcm/send")
  Call&lt;Message&gt; sendMessage(@Body Message message);
  
  }
  </code></pre>