I am creating an application that uses a login and I want to know if there is any way to create a new firebase token every time I login.
I need to create a token every time I log in as a user can have two different accounts and the notifications are different for each of these accounts.
Is there a way that I can create a new token every time a user logs in?
- Plugins:
import {
Plugins,
PushNotification,
PushNotificationToken,
PushNotificationActionPerformed,
Capacitor
} from '@capacitor/core';
- In this way I register the application and obtain the token to receive the notifications:
PushNotifications.requestPermission().then((permission) => {
PushNotifications.register();
});
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
// console.log(JSON.stringify('inciando notificaciones token ---------'));
console.log('My token: ' + JSON.stringify(token));
}
);
Even though I go back and called these services to try to get a different token, they don’t work for me, since they return the same token generated when starting the app for the first time the moment it is installed.
In a way, it is as if the token is registered with the mobile and a new token is only created when the app is reinstalled.
And what I’m looking for is to be able to create the new token every time the session is started instead of having to reinstall the app.
I hope you can help me and thank you very much.