title: Firebase Response for offline devices
body: <p>If I try to send a message to a device by using it's Firebase token and the device has no internet connection what response will be generated? Particularly I want to know if any "error" message will be generated or not? </p>
  
  <p>Take a look at the code below</p>
  
  <pre><code> while(rs.next())
          {
          URL url = new URL(API_URL_FCM);
          HttpURLConnection conn;
          conn = (HttpURLConnection) url.openConnection();
          conn.setUseCaches(false);
          conn.setDoInput(true);
          conn.setDoOutput(true);
          conn.setRequestMethod("POST");
          conn.setRequestProperty("Authorization","key="+AUTH_KEY_FCM);
          conn.setRequestProperty("Content-Type","application/json");
          JSONObject infoJson = new JSONObject();
          infoJson.put("title","Vehicle Alert");
          String alert=request.getParameter("alert");
          infoJson.put("body", alert);
          String token;
          OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
  
  
          token=rs.getString(1);
          JSONObject json = new JSONObject();
          json.put("to",token.trim());
          json.put("data", infoJson);
          wr.write(json.toString());
          out.println("&lt;br&gt;Message sent from server to firebase for Token : "+token+"&lt;/br&gt;");
           wr.flush();
           int status = 0;
           if( null != conn ){
               status = conn.getResponseCode();
              }
              if( status != 0){
                              if( status == 200 )
                              {//SUCCESS message
                               BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream()));
                               Boolean res=br.readLine().contains("error");
                               if(res)  //Remove Invalid Token(s)
                               {
                                   Statement st=con.createStatement();
                                   query="DELETE from Token WHERE token='"+token+"'";
                                   st.executeUpdate(query);
                                   out.println("&lt;br&gt;Unvalid Token removed from Database&lt;/br&gt;");
                               }
                              }
                              else if(status == 401)
                              {
                               //client side error
  </code></pre>
  
  <p>I don't want to be removing the token from my database just because the device is offline. The token should be removed if and only if it is no longer valid.
  Any suggestions?</p>