I stuck when I setup onBackgroundEvent #61
|
Hello I try to set up notifee, currently I test the by trriger display notification. the notification on foreground is work but when I tap notification when app in background state it show |
Replies: 1 comment
|
Hi @Nut41tank , and sorry for the late reply. From what you're describing, the warning:
means that NotifyKit is receiving an event while the app is in a background state, but no The background handler should be registered at the top level of your app entry point, for example in import { AppRegistry } from 'react-native';
import notifee, { EventType } from 'react-native-notify-kit';
notifee.onBackgroundEvent(async ({ type, detail }) => {
if (type === EventType.PRESS) {
console.log('Notification pressed in background:', detail.notification);
}
});
// AppRegistry.registerComponent(...)
When the app is already running in the background, a notification press can be routed through When a notification press causes the app to cold-start, the notification can also be available through So Could you check where you currently register If you already register it at the top level and still get this warning, please send me:
React Native 0.79.3 is within the currently declared supported range, so at the moment I don't see evidence that the React Native version itself is causing this warning. Thanks for reporting this. If your background handler is already registered correctly, I'll investigate the runtime path further. |
Hi @Nut41tank , and sorry for the late reply.
From what you're describing, the warning:
[notifee] no background event handler has been set. Set a handler via the "onBackgroundEvent" method.means that NotifyKit is receiving an event while the app is in a background state, but no
onBackgroundEvent()handler is registered at that moment.The background handler should be registered at the top level of your app entry point, for example in
index.js, outside of any React component and ideally beforeAppRegistry.registerComponent(...):