Push notifications not received by addListener

I am trying this example out to try push notifications:

The push notifications work fine when the app is not active.

However, the code to handle receipt of the push notification using Notifications.addListener is never called.

Does this still work with Expo? If so, what needs to change?

I am using expo 32.0.6.

@azahra can you send the addListner function and how you called that??

Here is the file in question with the addListener call:

@azahra Try this


Thanks for the suggestion but it made no difference.

you can also try this

Notification.addListener(‘Notification’, (Notification) => {this.handleNotification(Notification.Notification)});

if it will not work then

Notification.addEventListener(‘Notification’, (Notification) => {this.handleNotification(Notification.Notification)});

try this.

I have just realised there is a silly error in that example code. On line 48 there is a return before the notification gets registered:

Changing this to an await fixes the issue :slight_smile:

@azahra Glad you found your answer .

Good Day!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.