diff --git a/app/scripts/controllers/push-platform-notifications/services/services.ts b/app/scripts/controllers/push-platform-notifications/services/services.ts index da15be11c8d8..392cd22ad051 100644 --- a/app/scripts/controllers/push-platform-notifications/services/services.ts +++ b/app/scripts/controllers/push-platform-notifications/services/services.ts @@ -195,18 +195,21 @@ export async function listenToPushNotifications( const unsubscribePushNotifications = onBackgroundMessage( messaging, async (payload: MessagePayload): Promise => { - const typedPayload = payload; - - // if the payload does not contain data, do nothing try { - const notificationData: NotificationUnion = typedPayload?.data?.data - ? JSON.parse(typedPayload?.data?.data) + const data = payload?.data?.data + ? JSON.parse(payload?.data?.data) : undefined; - if (!notificationData) { + // if the payload does not contain data, do nothing + if (!data) { return; } + const notificationData = { + ...data, + type: data?.type ?? data?.data?.kind, + } as NotificationUnion; + const notification = processNotification(notificationData); onNewNotification(notification);