title: Firebase Cloud Messaging - Handling logout
body: <p>How do I handle situation, when user logs out of my application and I no longer want him to receive notifications to the device.</p>
  
  <p>I tried</p>
  
  <pre><code>FirebaseInstanceId.getInstance().deleteToken(FirebaseInstanceId.getInstance().getId(), FirebaseMessaging.INSTANCE_ID_SCOPE)
  </code></pre>
  
  <p>But I still receive the notifications to my device's <code>registration_id</code>.</p>
  
  <p>I also made sure that this is the token I should delete:</p>
  
  <pre><code>FirebaseInstanceId.getInstance().getToken(FirebaseInstanceId.getInstance().getId(), FirebaseMessaging.INSTANCE_ID_SCOPE)
  </code></pre>
  
  <p>or simply <code>FirebaseInstanceId.getInstance().getToken()</code>).</p>
  
  <p>I also tried <code>FirebaseInstanceId.getInstance().deleteInstanceId()</code>, but then the next time I call <code>FirebaseInstanceId.getInstance.getToken</code> I receive null (it works on the second try).</p>
  
  <p>I guess, after <code>deleteInstanceId</code> I could immediately call <code>getToken()</code> again, but it looks like a hack. And also there's <a href="https://stackoverflow.com/a/40589815/1118475">this answer</a> which states that it shouldn't be done, but it proposes deleting the token which apparently doesn't work.</p>
  
  <p>So what is the right method to handle this?</p>