title: How to get the firebase token?
body: <p>I am developing a test app that uses notifications via FCM. I am using Volley to send data from the device to the server(WAMP) but the token is always an empty string/a default value that I've written. I searched the internet but I still don't know why the token is not stored/generated(I'm new at coding.)
  One more thing: everytime I send the token, the toast shows me the "good one" text I've written there but it also gives me a lot of html code.
  Here are my files:
  MainActivity.kt</p>
  
  <pre><code>import android.content.Context
  import android.support.v7.app.AppCompatActivity
  import android.os.Bundle
  import android.util.Log
  import android.view.View
  import android.widget.Button
  import android.widget.Toast
  import com.android.volley.AuthFailureError
  import com.android.volley.Request
  import com.android.volley.Response
  import com.android.volley.toolbox.StringRequest
  
  class MainActivity : AppCompatActivity() {
      var url: String = "......"
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          var button: Button = findViewById(R.id.save_token)
          button.setOnClickListener(object : View.OnClickListener{
              override fun onClick(v: View?) {
                  val sharedPreferences =
                      applicationContext.getSharedPreferences(getString(R.string.FCM_PREF), Context.MODE_PRIVATE)
                  var token: String = sharedPreferences.getString(getString(R.string.FCM_TOKEN),"noToken")
  //                var token: String = "sss";
                  val request = object : StringRequest(Request.Method.POST, url,
                      Response.Listener { response -&gt;
                          Toast.makeText(this@MainActivity, "Good one $response", Toast.LENGTH_SHORT).show()
                          Log.i("My success", "" + response)
                      }, Response.ErrorListener { error -&gt;
                          Toast.makeText(this@MainActivity, "my error :$error", Toast.LENGTH_LONG).show()
                          Log.i("My error", "" + error)
  //                        println("Error $error")
                      }) {
                      @Throws(AuthFailureError::class)
                      override fun getParams(): Map&lt;String, String&gt; {
  
                          val params = HashMap&lt;String, String&gt;()
                          params.put("fcm_token", token)
  
                          return params
                      }
                  }
                  MySingleton.getmInstance(this@MainActivity).addToRequestQueue(request)
              }
          })
  
      }
  }
  </code></pre>
  
  <p>FcmInstanceIdService.java</p>
  
  <pre><code>public class FcmInstanceIdService extends FirebaseMessagingService{
      @Override
      public void onNewToken(String s) {
  
          String  recent_token = s;
          SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(getString(R.string.FCM_PREF),Context.MODE_PRIVATE);
          SharedPreferences.Editor editor = sharedPreferences.edit();
          editor.putString(getString(R.string.FCM_TOKEN), recent_token);
          editor.commit();
      }
  }
  </code></pre>
  
  <p>this is the log I get from the success toast:</p>
  
  <pre><code>2019-06-11 08:48:45.135 5684-5684/com.example.rares.firebaselast D/My success: connection success&lt;br /&gt;
      &lt;font size='1'&gt;&lt;table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'&gt;
      &lt;tr&gt;&lt;th align='left' bgcolor='#f57900' colspan="5"&gt;&lt;span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'&gt;( ! )&lt;/span&gt; Notice: Undefined variable: mysqli_close in C:\wamp64\www\firebase\fcm_insert.php on line &lt;i&gt;7&lt;/i&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;th align='left' bgcolor='#e9b96e' colspan='5'&gt;Call Stack&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;th align='center' bgcolor='#eeeeec'&gt;#&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Time&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Memory&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Function&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Location&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td bgcolor='#eeeeec' align='center'&gt;1&lt;/td&gt;&lt;td bgcolor='#eeeeec' align='center'&gt;0.0023&lt;/td&gt;&lt;td bgcolor='#eeeeec' align='right'&gt;402152&lt;/td&gt;&lt;td bgcolor='#eeeeec'&gt;{main}(  )&lt;/td&gt;&lt;td title='C:\wamp64\www\firebase\fcm_insert.php' bgcolor='#eeeeec'&gt;...\fcm_insert.php&lt;b&gt;:&lt;/b&gt;0&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;&lt;/font&gt;
      &lt;br /&gt;
      &lt;font size='1'&gt;&lt;table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'&gt;
      &lt;tr&gt;&lt;th align='left' bgcolor='#f57900' colspan="5"&gt;&lt;span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'&gt;( ! )&lt;/span&gt; Fatal error: Uncaught Error: Function name must be a string in C:\wamp64\www\firebase\fcm_insert.php on line &lt;i&gt;7&lt;/i&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;th align='left' bgcolor='#f57900' colspan="5"&gt;&lt;span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'&gt;( ! )&lt;/span&gt; Error: Function name must be a string in C:\wamp64\www\firebase\fcm_insert.php on line &lt;i&gt;7&lt;/i&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;th align='left' bgcolor='#e9b96e' colspan='5'&gt;Call Stack&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;th align='center' bgcolor='#eeeeec'&gt;#&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Time&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Memory&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Function&lt;/th&gt;&lt;th align='left' bgcolor='#eeeeec'&gt;Location&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td bgcolor='#eeeeec' align='center'&gt;1&lt;/td&gt;&lt;td bgcolor='#eeeeec' align='center'&gt;0.0023&lt;/td&gt;&lt;td bgcolor='#eeeeec' align='right'&gt;402152&lt;/td&gt;&lt;td bgcolor='#eeeeec'&gt;{main}(  )&lt;/td&gt;&lt;td title='C:\wamp64\www\firebase\fcm_insert.php' bgcolor='#eeeeec'&gt;...\fcm_insert.php&lt;b&gt;:&lt;/b&gt;0&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;&lt;/font&gt;
  </code></pre>