0

I'm implementing push notifications in an app, but I need to handle the notification to navigate to a specific screen. The problem is that my listener never fires, I searched a lot on google and tried a lot of things but none of them worked..

I'm using AWS SNS together with FCM to send the push.

What I have is this in my App.tsx:

componentDidMount() {
    Notifications.addListener(notification => {
        alert("IT WORKED")
    })
}

But ofcourse this alert is never called..

I read this issue https://github.com/expo/expo/issues/4183 and it seems that the format of the push matters, so right now I'm sending the push in this format:

{
  "GCM": "{ \"notification\": { \"message\": \"Sample message for Android endpoints\", \"title\": \"Hello You...\" } }"
}

And I receive the push, but when I click on it to open the app, doesn't fire my listener, but in the issue the guy said to send like this:

{
"GCM": "{ \"data\": { \"message\": \"Sample message for Android endpoints\", \"title\": \"Hello world...\", \"body\": \"msg body\", \"experienceId\": \"@expousername/app-slug\" } }"
}

But if I send like this, I don't even receive the push.

What I'm doing wrong?

  • do u have any fix? – ALSP Apr 10 '20 at 08:11
  • @ALSP no, but talking with other people I discovered that if you are using expo and firebase and sending the push directly through firebase console, you are probably getting the token with `Notifications.getDevicePushTokenAsync`, but this token is the device token and firebase just sends the push notification to your device, but not for your app, which means that you can't handle the notification inside your app – Gustavo Henrique Morales de Me Apr 13 '20 at 17:53
  • @GustavoHenriqueMoralesdeMe Did you confirm this? The following guide makes me think it should be possible... https://docs.expo.io/push-notifications/sending-notifications-custom – Pedro A Sep 11 '20 at 02:52
  • That guide says "The experienceId field is required, otherwise your notifications will not go through to your app." – phatmann Jun 23 '21 at 09:49

0 Answers0