title: Android Firebase Notifications not being shown using custom server
body: <p>I am trying to send notifications to my android devices using Firebase Cloud Messaging. Apparently everything is OK. I get an answer for my HTTP request:</p>
  
  <pre><code>Response Code : 200
  
  {"message_id": **ID here** }
  </code></pre>
  
  <p>But I have an emulator with the APK installed and no notifications are being received, not even when the app is on the foreground.</p>
  
  <p>Everything works fine when messages are sent through the Firebase console.</p>
  
  <p>Anyone can help me to find out what's wrong?</p>
  
  <pre><code>import java.io.BufferedReader;
      import java.io.IOException;
      import java.io.InputStreamReader;
      import java.io.OutputStreamWriter;
      import java.io.UnsupportedEncodingException;
      import java.net.HttpURLConnection;
      import java.net.URL;
      import java.util.Base64;
  
  
      public class Main {
  
          public static void main(String[] args) throws UnsupportedEncodingException, IOException {
  
              String apiKey = "AI...LoU"; //My key here
  
              String out = "{\"notification\":{\"title\": \"My title\", \"text\": \"My text\"}, \"to\":\"/topics/all\",\"data\": {\"key\": \"value\"}}";
  
              URL url = new URL("https://fcm.googleapis.com/fcm/send");
  
              String credentials = "key=" + apiKey;
              //String basicAuth = "Basic " + new String(Base64.getEncoder().encodeToString(credentials.getBytes()));
  
              HttpURLConnection conn = (HttpURLConnection) url.openConnection();
              conn.setUseCaches(false);
              conn.setDoInput(true);
              conn.setDoOutput(true);
              conn.setRequestMethod("POST");
              conn.setRequestProperty( "Content-Type", "application/json" );
              conn.setRequestProperty("Authorization", credentials);
  
              conn.connect();
  
              OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
              wr.write(out);
              wr.flush();
  
              int responseCode = conn.getResponseCode();
              System.out.println("Response Code : " + responseCode);
  
              BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
              String inputLine;
              while ((inputLine = in.readLine()) != null) {
                  System.out.println(inputLine);
              }
              in.close();
              wr.close();
          }
  
      }
  </code></pre>