title: Can i disable push notifications via Firebase?
body: <p>I am implementing push notification in my app after having it for IOS for a while.</p>
  
  <p>Use case: I have user login, and accounts stored on our servers. I only want to send push notifications when a user is logged in, and only for the user currently logged in. Notifications are targeted to the individual user.</p>
  
  <p>To do this, i fetch the token using </p>
  
  <pre><code>FirebaseInstanceId.getInstance().getToken()
  </code></pre>
  
  <p>, send push token to our server when user logs in, and remove it on logout.</p>
  
  <p>Everything works as far as registering token, sending the token etc., HOWEVER, there could be scenarios where this doesn't work, for example if a user logs out with flight mode, so our server still has the token and thinks it should still send them.</p>
  
  <p>On IOS, there are two local functions, register/unregisterforremotenotifications, that basically turns notifications on/off, regardless of whether my server could be contacted.  I can call these on login/logout, and IOS won't show any remote notifications for my app, and i'm safe.</p>
  
  <p>However, with Firebase, i can send the token to the server on login - 
  for logout, however, its more complex since there's no "local" system-function to call that i can find.</p>
  
  <p>The best thing i've figured out, is to always send a 'Data' notification, 
  <a href="https://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase?noredirect=1&amp;lq=1">as described in this question</a>,
  so that my notification service always gets called, even in the background, and there check if i am logged in, and not show the notification if i'm not.</p>
  
  <p>However, the notification for the wrong user will still be sent to the phone, and it's a risk, for example if i, god forbid would have a bug... or the notification gets logged somewhere in the system.</p>
  
  <p>Sooo, my question is if there's any way to disable notifications on logout via Firebase?</p>
  
  <p>I hope this makes sense, thoughts much appreciated!</p>