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); }); }, 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