Expo Push Notifications Not Working

Please provide the following:

  1. SDK Version: 38
  2. Platforms(Android/iOS/web/all): Android

I have started working on the POC for push notifications and checked out this : https://docs.expo.io/push-notifications/overview/. I directly copy pasted this code and tried to run on my devices. I am able to generate push notification by click on button but these 2 listeners are not getting fired : Notifications.addNotificationReceivedListener and Notifications.addNotificationResponseReceivedListener. Also, the title and message content are not getting updated.

Can someone please help me solve this? Is there anything missing in official docs. I have generated google-services.json and put it in app.json

Hey @rushijeavio, are you testing within the Expo client or as a standalone app?

Cheers,
Adam

Hi @adamjnav,

I am testing within the expo client

hi
here has the same problem

SDK Version: 38

I found that the api using sdk 37 is still useful, hope it will help you.

import * as Notifications from 'expo-notifications';
import { Notifications as Notifications2 } from 'expo';

Notifications.addNotificationReceivedListener((notification) => {
  // It didn't work for me
});

Notifications2.addListener((data) => {
  // This works for me
});
2 Likes

Hi @midoushitongtong,

Thanks for informing. But I want to stick to SDK 38 as I want to use latest react-native.

I have just ran into this same issue. I am able to successfully send a notification to my phone using android, but when I click on it, neither the addNotificationReceivedListener or the addNotificationResponseReceivedListener listeners are getting fired. I am using expo 38

I forgot to mention, I did indeed try what @midoushitongtong mentioned in expo 38, and the addListener function does get fired

for a long time did not understand why it does not work, “expo-notifications”: “~0.5.0”,“expo”: “~38.0.8”
Thank, it’s bug…

Hi @dpisarevskiy,

Can you please elaborate? If you have seen this is a bug on any place, could you please send the link?

I have no information, for two days I try to setup push notification on Android and FCM. Sending push notification via FCM is not documented, only if you using expo servers.
When I send to FCM in this callback is got nothing:
Notifications2.addListener((data) => {
// This works for me
console.log('App was opened by notification: ', data)
setNotification(data);

});

Having this same issue with the update to Expo 38. The push notification comes to the device, but the listeners do not fire. Works on iphone.

After days this works!! Expo it’s a blessing but sometimes it’s a real mess!!

@ivanjzr what was your solution?

I have the same issue, it stopped working, any clue why it’s not firing the message

I updated to expo 38, but reverted the notifications to the old way using import { Notifications } from 'expo'; and .addListener. It’s not ideal.

Did you specify to use the new notification api in the app.json?
That caused some trouble for me once

2 Likes

This was for sure the problem

How to do that?

Thank you it works. Found it in doc.

{
  "expo": {
    ...
    "android": {
      ...
      "useNextNotificationsApi": true,
    }
  }
}
1 Like