[FIX] App crashes when opening a notification while app is closed (#3629)

This commit is contained in:
Gleidson Daniel Silva 2022-01-19 17:37:06 -03:00 committed by GitHub
parent 2946c4724e
commit 9d25636cf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -9,4 +9,5 @@ export interface INotification {
from: string;
image: string;
soundname: string;
getData: () => INotification;
}

View File

@ -16,9 +16,10 @@ interface IEjson {
messageId: string;
}
export const onNotification = (notification: INotification): void => {
if (notification) {
export const onNotification = (push: INotification): void => {
if (push) {
try {
const notification = push?.getData();
const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson);
const types: Record<string, string> = {

View File

@ -22,7 +22,7 @@ class PushNotification {
// TODO REDUX MIGRATION TO TS
const { background } = reduxStore.getState().app;
if (background) {
this.onNotification(notification?.getData());
this.onNotification(notification);
}
completion();
});

View File

@ -16,7 +16,7 @@ class PushNotification {
});
NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => {
this.onNotification(notification?.getData());
this.onNotification(notification);
});
}