[FIX] App crashes when opening a notification while app is closed (#3629)
This commit is contained in:
parent
2946c4724e
commit
9d25636cf4
|
@ -9,4 +9,5 @@ export interface INotification {
|
||||||
from: string;
|
from: string;
|
||||||
image: string;
|
image: string;
|
||||||
soundname: string;
|
soundname: string;
|
||||||
|
getData: () => INotification;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,10 @@ interface IEjson {
|
||||||
messageId: string;
|
messageId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const onNotification = (notification: INotification): void => {
|
export const onNotification = (push: INotification): void => {
|
||||||
if (notification) {
|
if (push) {
|
||||||
try {
|
try {
|
||||||
|
const notification = push?.getData();
|
||||||
const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson);
|
const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson);
|
||||||
|
|
||||||
const types: Record<string, string> = {
|
const types: Record<string, string> = {
|
||||||
|
|
|
@ -22,7 +22,7 @@ class PushNotification {
|
||||||
// TODO REDUX MIGRATION TO TS
|
// TODO REDUX MIGRATION TO TS
|
||||||
const { background } = reduxStore.getState().app;
|
const { background } = reduxStore.getState().app;
|
||||||
if (background) {
|
if (background) {
|
||||||
this.onNotification(notification?.getData());
|
this.onNotification(notification);
|
||||||
}
|
}
|
||||||
completion();
|
completion();
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ class PushNotification {
|
||||||
});
|
});
|
||||||
|
|
||||||
NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => {
|
NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => {
|
||||||
this.onNotification(notification?.getData());
|
this.onNotification(notification);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue