Silent push notifications
Brent Vatne
> They can be used to inform the application of new content without having the user informed. Instead of displaying a notification alert, the application will be awakened in background [...]. You then have the opportunity to process any information transparently for the user :
>
> Download some content
> Synchronize some elements,
> Inform the user directly within the application when they open it back up
Steve Moretz
For anyone needing this now, I did too and used rn-firebase instead, you can easily use it with EAS build as they have the necessary config plugins, it was very simple to set up, and this feature works out of the box. (Tested the whole thing myself)
oussamakh
Still need this feature , when app background or killed I don't wonna the push notification to be shown
M
Mehmet Beydoğan
Such a basic feature missing on Expo, its unbelievable...
Steve Moretz
For anyone needing this now, I did too and used rn-firebase instead, you can easily use it with EAS build as they have the necessary config plugins, it was very simple to set up, and this feature works out of the box. (Tested the whole thing myself)
Chen W
Steve Moretz: just making sure I understand, you're using the Firebase Admin SDKs to send the notification instead of the Expo Push API like what's documented here. https://rnfirebase.io/messaging/usage#data-only-messages
And on the frontend, you're using react-native messaging instead of expo-notifications package?
Steve Moretz
Chen W: That is correct, but remember you can use any backend sdk depending on your backend language, so you don't exactly need to do what is provided in the link you provided, but the concept is the same you don't pass notification and only data and it's done! For the front-end also you are correct in the same page you'll find some events for receiving events on background : https://rnfirebase.io/messaging/usage#background--quit-state-messages
and foreground:
And these two are all you need beside setting up, maybe you won't even need the background ones either.
Di Qi
For iOS, is this the same thing as Silent APNs?
sendylo app
Any news on this? I really need this to track app uninstalls
Steve Moretz
sendylo app: May I ask how would you track your uninstall via this?
sendylo app
Steve Moretz: when the user uninstall your app, silent push notifications will fail with a specific message. Based on that, you know it’s uninstalled.
The idea is to send those silent messages regularly to check. Maybe once a day or so. Thats the only way I found to track uninstalls
Steve Moretz
sendylo app: wow thank you that's a very great idea! Well I didn't know about this, and implemented a mechanism for knowing if the user has uninstalled the app, it's not as good of course but you could just somehow manage to save the last time a user uses your app everyday on your server and if you have users who are inactive in a long time consider them uninstalled, not great and doesn't work instantly (for each user that interval needs to be passed) but it works, better than nothing...
kesylo
Steve Moretz: yeah. That’s why these silent notifications are needed. I have already searched all over the web on how to get app uninstalls on expo 😥. If someone has another solution, please help
kesylo
Steve Moretz: did you succeed to make silent notifications work with the content-available flag on expo?
Steve Moretz
kesylo: as I mentioned earlier, the document is unclear and it is very hard to make it work right now so I gave it up and switched to websockets for now, but your use case is different. If you really need it you have to go a different route check out Micheal Wood's answer below.
kesylo
Steve Moretz: ok. Can you explain how you used the webdsockets to detect app uninstalls ?
Steve Moretz
kesylo: Unfortunately as I mentioned my use case is different, you can't use websocket to monitor uninstalls, websocket only works on the foreground, you need some kind of pushing one way would be to install fcm and use that, that has support for background notifications but we had to eject a long time ago right now this might be possible with EAS without ejecting, however I'm not sure how.
Steve Moretz
Expo sdk 42 brought this feature but no good examples are available,
the “content-available” flag ...
This flag should make it silent( haven't tested but this exact key is used with fcm and apns for making the notification silent), but can we pass it to the expo notification service api?According to official expo's github no.
So here's a feature request for start:
Still there is a lot of confusion between background notification and silent notification and the document is super unclear, I couldn't test it myself yet.
Wodin
If I needed this now I would give it a try with react-native-push-notification, but it will need a Config Plugin and EAS Build.
Steve Moretz
Wodin:
Why not add this feature to the new expo-notification?
Wodin
Steve Moretz: I am just an Expo user. I don't work for them :)
Steve Moretz
Wodin: Sorry I always though you did :)
Lars Moelleken
Wodin: They should pay you for your work. 🤔
Wodin
Lars Moelleken: 😂
Steve Moretz
I think this possible with the new expo-notification package config right?
Luca Palomba
Steve Moretz: How?
Steve Moretz
Luca Palomba:someone in discord of expo was once talking about it, there are three keys you set in the new expo-notification config one of them apparently does something like this, I have not tested it myself however and don't remember which one of the three.
Luca Palomba
Steve Moretz: Really? I need to find it!
Steve Moretz
Luca Palomba:
Here :
You can find this :
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});
It shall be one of these I guess this one "shouldShowAlert" just set it to true or false and see if that does the trick, if it does please let us know too, if it doesn't please try changing the other two.
Again I have not tested it myself just heard about it on the discord channel.
I remember another way I did it that could remove the notification and keep it silent when the app is foregrounded (by listening and cancelling the notification), but had no way to disable it when it is backgrounded, but this that I mentioned above probably solves the problem for backgrounded mode as well.
Luca Palomba
Steve Moretz: Yes i've just implemented this method on my app and as you say works only when foreground. So in background notifications continues to be showed and this, obiviously is not wha a silent notifcations should do.
Steve Moretz
Luca Palomba: Did you put shouldShowAlert to false? as I mentioned I used another method to get rid of the frontend notifications,I thought shouldShowAlert : false is supposed to fix the background as well, isn't it?
Luca Palomba
Steve Moretz: Confirm, isn't. I admit I didn't try a fresh install but i don't know if can change something or not.
Satchel Grant
For anyone who's struggling, I think BackgroundFetch https://docs.expo.io/versions/latest/sdk/background-fetch/ is a viable work around.
I would still like the silent notifications feature though.
Vlad Mustiață
Trying to implement AppsFlyer's app uninstall tracking for Android and this triggers some 'empty' notifications which are meant to be silent. But somehow the app don't see them as silent.
Would be awesome to have this.
Load More
→