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.