react-native-fcm icon indicating copy to clipboard operation
react-native-fcm copied to clipboard

Sending `FCMNotificationReceived` with no listeners registered.

Open googl3r opened this issue 9 years ago • 6 comments

Hi, i am using FCM with Firebase functions to send notifications based on some effects,

it works fine send notifications and i receive them but when i click on the notification i get nothing and in the logs i get this message: Sending FCMNotificationReceived with no listeners registered.

in my functions her is the payload sent:

   const payload = {
            notification: {
                'title': formatedData.titre,
                'body': formatedData.commande
            }
        };
        const options = {
            priority: "high",
            content_available: true,
        };
        return admin.messaging()
            .sendToDevice("user_token", payload, options);
    })

and in my react i have this in componentDidMount:

    componentDidMount() {
    FCM.requestPermissions();

    FCM.getFCMToken().then(token => {
      console.log("TOKEN (getFCMToken)", token);
      this.setState({token: token});
    });
    FCM.subscribeToTopic('mes-annonces');

    FCM.getInitialNotification().then(notif => {
      console.log("INITIAL NOTIFICATION", notif);
      alert('got a notification '+notif);
    });

    this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
        console.log('event notification'+notif);
        alert('got notif' + notif);

        if(notif.opened_from_tray) {
            alert('clicked on notification');
            console.log('got a opened_from notification');
        }
        if(notif.local_notification) {
            console.log('got a local notification');
        }

        if (Platform.OS === 'ios') {
            switch (notif._notificationType) {
                case NotificationType.Remote:
                    notif.finish(RemoteNotificationResult.NewData); //other types available: RemoteNotificationResult.NewData, RemoteNotificationResult.ResultFailed
                    break;
                case NotificationType.NotificationResponse:
                    notif.finish();
                    break;
                case NotificationType.WillPresent:
                    console.log('in the method');
                    notif.finish(WillPresentNotificationResult.All); //other types available: WillPresentNotificationResult.None
                    break;
              }
            }
        this.showLocalNotification(notif);
    });

    FCM.on(FCMEvent.RefreshToken, token => {
        console.log(token);
    })
    }

googl3r avatar Jul 29 '17 15:07 googl3r

sorry it was my fault, this code was in file that wasn't mount :/ the issue can be closed

googl3r avatar Jul 29 '17 23:07 googl3r

Hello @googl3r

I am also getting this issue and i have the same code which is working fine for Android but giving this error in iOS.

Please guide.

aditya27dev avatar Sep 08 '17 04:09 aditya27dev

Any update on that?

yqbk avatar Sep 12 '18 08:09 yqbk

Any solutions for that ??

vicky462 avatar Nov 14 '18 05:11 vicky462

Any solutions for that ?? [2]

never00miss avatar Jan 11 '19 10:01 never00miss

i have same issue and i am not even recieving any notification but "Sending FCMNotificationReceived with no listeners registered" every time i send message from server

can someone please tell whether this issue from APNs or Firebase wrong setting or firebase cocoapods i installed

if it from cocoapod install then i will remove cocoapod and install firebase sdk manualy

yusuf987 avatar Mar 31 '19 06:03 yusuf987