Push Notifications just stopped working?

#1

Hey everyone. So I’ve had push notifications working well on my app (it’s still testing so running via expo client) until recently I noticed that notifications had stopped. Not just for me but all users that are testing the app.

I am running a Rails API as my back end server and I have verified that my send notifications method is being called, it has the push token, message etc. I have also tried calling exponent.publish( etc in my Rails console, so I’m pretty certain it’s not the back end, I’m thinking it may be the listener. Though FWIW calling exponent.publish etc in the rails console returns nil, not sure if that’s expected or not.

I haven’t changed it though, so I’m baffled at what it might be. I’ve been trying stuff all evening but have no idea what’s going on. Is there any way I can test the expo push service is receiving the messages?

Note - I realise it doesn’t work on the simulator, for this purpose I am trying it on my device itself, running locally.

In my React Native code, I have

import registerForNotifications from '../../services/pushNotifications' - this is the service that asks for permission, gets previous token from local storage etc. I can confirm this is being called from componentDidMount() in my code and it seems to be working fine. Also in my componentDidMout() I have the following (note a console log right inside of this never gets called, I don’t know if it’s supposed to or not):

    Notifications.addListener((notification) => {
      const { data: { text }, origin } = notification
      if (origin === 'received' && text) {
        Alert.alert(
          'New Push Notification',
          text,
          [{ text: 'Ok' }]
        )
      }
    })

Would be grateful if anyone can help! I’m totally confused.

0 Likes

#2

Ok I’ve worked out it’s not actually the listener. I worked out I am able to send a post request using the HTTP/2 API via Postman and the app receives the message. So for whatever reason, I guess it’s the Rails gem that isn’t working for me anymore. I might just have to make a post request from Rails instead.

0 Likes

#3

Seems there is a PR to address some issues with this gem… it doesn’t look as if this repo is maintained anymore. It would be good if someone at expo could address this?

https://github.com/expo/exponent-server-sdk-ruby/pull/2

0 Likes