prepare for foreground notifications
This commit is contained in:
@@ -301,10 +301,10 @@ class TinodeWeb extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Notifiy Tinode that a push message was received from the server.
|
// Notifiy Tinode that a push message was received from the server.
|
||||||
handlePushMessage(payload) {
|
handlePushMessage(data) {
|
||||||
if (payload.data.what == 'msg' && Tinode.isChannelTopicName(payload.data.topic)) {
|
if (data.what == 'msg' && Tinode.isChannelTopicName(data.topic)) {
|
||||||
// The last argument is a fake user Id: otherwise the update is seen as one from the current user.
|
// The last argument is a fake user Id: otherwise the update is seen as one from the current user.
|
||||||
this.tinode.oobNotification(payload.data.topic, payload.data.seq, 'fake-uid');
|
this.tinode.oobNotification(data.topic, data.seq, 'fake-uid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,8 +330,10 @@ class TinodeWeb extends React.Component {
|
|||||||
this.requestPushToken();
|
this.requestPushToken();
|
||||||
});
|
});
|
||||||
|
|
||||||
// FCM pushes for channels have to be handled even when the app is in the foreground.
|
// Handhe FCM pushes
|
||||||
this.fbPush.onMessage(this.handlePushMessage);
|
// (a) for channels always,
|
||||||
|
// (b) pushes when the app is in foreground but has not focus.
|
||||||
|
this.fbPush.onMessage(payload => { this.handlePushMessage(payload.data); });
|
||||||
|
|
||||||
return reg;
|
return reg;
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
@@ -421,6 +423,8 @@ class TinodeWeb extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOnline(online) {
|
handleOnline(online) {
|
||||||
|
console.log("handleOnline", online);
|
||||||
|
|
||||||
if (online) {
|
if (online) {
|
||||||
this.handleError();
|
this.handleError();
|
||||||
clearInterval(this.reconnectCountdown);
|
clearInterval(this.reconnectCountdown);
|
||||||
|
|||||||
+5
-3
@@ -5056,9 +5056,9 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
return tinode;
|
return tinode;
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePushMessage(payload) {
|
handlePushMessage(data) {
|
||||||
if (payload.data.what == 'msg' && tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default().isChannelTopicName(payload.data.topic)) {
|
if (data.what == 'msg' && tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default().isChannelTopicName(data.topic)) {
|
||||||
this.tinode.oobNotification(payload.data.topic, payload.data.seq, 'fake-uid');
|
this.tinode.oobNotification(data.topic, data.seq, 'fake-uid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5193,6 +5193,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOnline(online) {
|
handleOnline(online) {
|
||||||
|
console.log("handleOnline", online);
|
||||||
|
|
||||||
if (online) {
|
if (online) {
|
||||||
this.handleError();
|
this.handleError();
|
||||||
clearInterval(this.reconnectCountdown);
|
clearInterval(this.reconnectCountdown);
|
||||||
|
|||||||
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
Reference in New Issue
Block a user