From 4ebd88e323f43a017c53698548456815c9f7b879 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 25 Sep 2024 09:46:08 +0800 Subject: [PATCH 1/2] fix: android 11 crash when click foreground notifications (expo-notifications) (#5913) --- patches/expo-notifications+0.27.6.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 patches/expo-notifications+0.27.6.patch diff --git a/patches/expo-notifications+0.27.6.patch b/patches/expo-notifications+0.27.6.patch new file mode 100644 index 00000000000..6195b9fcda3 --- /dev/null +++ b/patches/expo-notifications+0.27.6.patch @@ -0,0 +1,14 @@ +diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt +index 85deee1..4b440da 100644 +--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt ++++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt +@@ -454,7 +454,8 @@ open class NotificationsService : BroadcastReceiver() { + // [notification trampolines](https://developer.android.com/about/versions/12/behavior-changes-12#identify-notification-trampolines) + // are not allowed. If the notification wants to open foreground app, + // we should use the dedicated Activity pendingIntent. +- if (action.opensAppToForeground()) { ++ // https://github.com/expo/expo/pull/30207 ++ if (action.opensAppToForeground() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + val notificationResponse = getNotificationResponseFromBroadcastIntent(intent) + return ExpoHandlingDelegate.createPendingIntentForOpeningApp(context, intent, notificationResponse) + } From 15075a305497cb850780922b633ea2a1dcbc9ecf Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 25 Sep 2024 10:56:05 +0800 Subject: [PATCH 2/2] fix: fix the navigation when a notification is clicked(OK-32655) (#5912) --- packages/shared/src/utils/notificationsUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/utils/notificationsUtils.ts b/packages/shared/src/utils/notificationsUtils.ts index 569b9a146d9..544fbe58a73 100644 --- a/packages/shared/src/utils/notificationsUtils.ts +++ b/packages/shared/src/utils/notificationsUtils.ts @@ -1,3 +1,4 @@ +import { StackActions } from '@react-navigation/native'; import { isNil } from 'lodash'; import type { IAppNavigation } from '@onekeyhq/kit/src/hooks/useAppNavigation'; @@ -113,11 +114,11 @@ async function navigateToNotificationDetail({ params, }); } else { - // navigate\pushModal\pushFullModal - global.$navigationRef.current?.navigate( + const pushAction = StackActions.push( modalParams.screen, modalParams.params, ); + global.$navigationRef.current?.dispatch(pushAction); } } }