From e60eca230265e9e0891347f41ede9fb7a316409d Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Thu, 5 Feb 2026 14:48:48 -0500 Subject: [PATCH 1/2] fix(app, android): avoid NullPointerException in isAppInForeground check --- .../java/io/invertase/firebase/common/SharedUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/app/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java b/packages/app/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java index b98134068b..a579ade3aa 100644 --- a/packages/app/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +++ b/packages/app/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java @@ -141,7 +141,8 @@ public static boolean isAppInForeground(Context context) { if (taskInfo.size() > 0) { ActivityManager.RecentTaskInfo task = taskInfo.get(0).getTaskInfo(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - currentActivity = task.baseActivity.getShortClassName(); + currentActivity = + task.baseActivity != null ? task.baseActivity.getShortClassName() : ""; } else { currentActivity = task.origActivity != null From 56232af630ec0a1613bb2be220f34dfe0efcdf70 Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Thu, 5 Feb 2026 17:30:18 -0500 Subject: [PATCH 2/2] test(messaging): fix FCM cloud function to initialize admin app forgot to do that after converting to modular, so it was returning an internal error, it works in testing (using rnfbdemo/make-demo.sh) with this fix deployed also made sure to deploy in correct project by adding a `firebase use` command to the functions deploy package.json script --- .github/workflows/scripts/functions/package.json | 2 +- .github/workflows/scripts/functions/src/sendFCM.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scripts/functions/package.json b/.github/workflows/scripts/functions/package.json index f3ec7571b7..c6f6a4920f 100644 --- a/.github/workflows/scripts/functions/package.json +++ b/.github/workflows/scripts/functions/package.json @@ -5,7 +5,7 @@ "serve": "build && firebase emulators:start --only functions", "shell": "build && firebase functions:shell", "start": "shell", - "deploy": "firebase deploy --only functions", + "deploy": "firebase use react-native-firebase-testing && firebase deploy --only functions", "logs": "firebase functions:log" }, "engines": { diff --git a/.github/workflows/scripts/functions/src/sendFCM.ts b/.github/workflows/scripts/functions/src/sendFCM.ts index 44c7fa0546..3a78927b5a 100644 --- a/.github/workflows/scripts/functions/src/sendFCM.ts +++ b/.github/workflows/scripts/functions/src/sendFCM.ts @@ -10,6 +10,7 @@ import { logger } from 'firebase-functions/v2'; import { CallableRequest, onCall } from 'firebase-functions/v2/https'; import { getMessaging, TokenMessage } from 'firebase-admin/messaging'; +import { getAdminApp } from '.'; // Note: this will only work in a live environment, not locally via the Firebase emulator. export const sendFCM = onCall( @@ -19,8 +20,13 @@ export const sendFCM = onCall( logger.info('Sleeping this many milliseconds: ' + (delay ?? 0)); setTimeout(async () => { logger.info('done sleeping'); - const result = await getMessaging().send(message); - return { messageId: result }; + try { + const result = await getMessaging(getAdminApp()).send(message); + return { messageId: result }; + } catch (e) { + logger.error(`There was a problem: ${e}`); + return { error: e }; + } }, delay ?? 0); }); },