clear device token when requested
This commit is contained in:
@@ -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});
|
||||
|
||||
+6
-6
@@ -5044,15 +5044,12 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
if (!this.state.firebaseToken) {
|
||||
this.togglePushToken(true);
|
||||
} else {
|
||||
this.tinode.setDeviceToken(this.state.firebaseToken, true);
|
||||
this.tinode.setDeviceToken(this.state.firebaseToken);
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log("Failed to register service worker:", err);
|
||||
});
|
||||
this.fbPush.onMessage(payload => {
|
||||
console.log("got fg push message", payload.data);
|
||||
});
|
||||
} catch (err) {
|
||||
this.handleError(formatMessage(messages.push_init_failed), 'err');
|
||||
console.log("Failed to initialize push notifications", err);
|
||||
@@ -5788,7 +5785,9 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
this.fbPush.onTokenRefresh(() => {
|
||||
this.requestPushToken();
|
||||
});
|
||||
this.fbPush.onMessage(payload => {});
|
||||
this.fbPush.onMessage(payload => {
|
||||
console.log("got fg push message", payload.data);
|
||||
});
|
||||
}
|
||||
|
||||
togglePushToken(enabled) {
|
||||
@@ -5827,6 +5826,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
desktopAlerts: false,
|
||||
firebaseToken: null
|
||||
});
|
||||
this.tinode.setDeviceToken(null);
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
@@ -5842,7 +5842,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
requestPushToken() {
|
||||
this.fbPush.getToken().then(refreshedToken => {
|
||||
if (refreshedToken != this.state.firebaseToken) {
|
||||
this.tinode.setDeviceToken(refreshedToken, true);
|
||||
this.tinode.setDeviceToken(refreshedToken);
|
||||
_lib_local_storage_js__WEBPACK_IMPORTED_MODULE_14__.default.setObject('firebase-token', refreshedToken);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
-8
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user