Skip to content

Commit

Permalink
test: set FCM background handler in index.js per docs
Browse files Browse the repository at this point in the history
this should have been in index.js so it could be registered as
a background handler prior to AppRegistry registration of the app
  • Loading branch information
mikehardy committed Dec 16, 2024
1 parent d3a2887 commit 7359069
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 0 additions & 10 deletions tests_react_native/example/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ async function onMessage(message: RemoteMessage): Promise<void> {
// });
}

async function onBackgroundMessage(message: RemoteMessage): Promise<void> {
console.log('onBackgroundMessage New FCM Message', message);
// await Notifee.displayNotification({
// title: 'onMessage',
// body: `with message ${message.messageId}`,
// android: { channelId: 'default', tag: 'hello1' },
// });
}

firebase.messaging().setBackgroundMessageHandler(onBackgroundMessage);
function Root(): any {
const [id, _] = React.useState<string | null>(null);

Expand Down
6 changes: 6 additions & 0 deletions tests_react_native/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { AppRegistry } from 'react-native';
import '@react-native-firebase/messaging';
import firebase from '@react-native-firebase/app';
import notifee from '@notifee/react-native';

import App from './example/app';

firebase.messaging().setBackgroundMessageHandler(async message => {
console.log('onBackgroundMessage New FCM Message', message);
});

notifee.onBackgroundEvent(async event => {
console.log('notifee.onBackgroundEvent triggered: ' + JSON.stringify(event));
});
Expand Down

0 comments on commit 7359069

Please sign in to comment.