clear device token when requested

This commit is contained in:
or-else
2021-02-21 16:48:27 -08:00
parent 50344f3cd5
commit 99423dd04f
7 changed files with 24 additions and 20 deletions
+4 -2
View File
@@ -241,7 +241,7 @@ class TinodeWeb extends React.Component {
if (!this.state.firebaseToken) {
this.togglePushToken(true);
} else {
this.tinode.setDeviceToken(this.state.firebaseToken, true);
this.tinode.setDeviceToken(this.state.firebaseToken);
}
}
}).catch((err) => {
@@ -1004,6 +1004,8 @@ class TinodeWeb extends React.Component {
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
localStorage.removeItem('firebase-token');
this.setState({desktopAlerts: false, firebaseToken: null});
// Inform the server that the token was deleted.
this.tinode.setDeviceToken(null);
});
} else {
this.setState({desktopAlerts: false, firebaseToken: null});
@@ -1014,7 +1016,7 @@ class TinodeWeb extends React.Component {
requestPushToken() {
this.fbPush.getToken().then((refreshedToken) => {
if (refreshedToken != this.state.firebaseToken) {
this.tinode.setDeviceToken(refreshedToken, true);
this.tinode.setDeviceToken(refreshedToken);
LocalStorageUtil.setObject('firebase-token', refreshedToken);
}
this.setState({firebaseToken: refreshedToken, desktopAlerts: true});