Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/scripts/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/scripts/functions/src/sendFCM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading