0

I use the lib https://github.com/zo0r/react-native-push-notification

The callback onNotification is fired only when foreground is true but when the app is closed the callback is never invoked

My app entry point is

    return (
        <Provider store={store}>
            <PushNotificationController/>
            <AppContainer ref={navigatorRef => {
                NavigationService.setTopLevelNavigator(navigatorRef);
            }}/>
        </Provider>
    );

and PushNotificationController

export const PushNotificationComponent = (props: PushNotificationProps) => {

    useEffect(() => {
        configurePushNotification(onRegister,onNotif)
    },[])

    const onRegister = (token: string) => {
        console.log('token', token);
    }

    const onNotif = (notif: any) => {
        console.log('notification ',notif);
        // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
        notif.finish(PushNotificationIOS.FetchResult.NoData);
    }

    return (null)
};

The method

configurePushNotification

is the same as the example here: https://github.com/zo0r/react-native-push-notification/blob/master/example/NotifService.js

Can someone help me? Thanks!

Humanbeings
  • 89
  • 2
  • 8

0 Answers0