0

I am building an app has push notification.I want firebase token based on user login, but I not using FirebaseAuth. So need token based on user login in flutter app.

I tried below one but it is generating same token for new login

String? token = await FireBaseNotificationConfiguration().messaging.getToken();

So is there any possible wat to get new firebase token every time when user login with new account (in same device) and clear token after logout app?

Thank in advance!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Adhi
  • 43
  • 8
  • if you want to store token somewhere in a database it should work when you send notification through your backend to that token. – Wali Seddiqi Jun 30 '22 at 12:51
  • yeah issue is if i login with some other account then it generates the same existing token it's generating new token – Adhi Jun 30 '22 at 13:09
  • so on login method I guess you can get that token and update it with the new logged user and remove the token for the previous user from your database. So next time when you want to send that specific user a notification they will receive it from the device they use currently. notification token is generated per device. – Wali Seddiqi Jun 30 '22 at 14:33

1 Answers1

1

Delete the token when a user logs out and then you get a new token when a new user logs in.

user18309290
  • 5,777
  • 2
  • 4
  • 22