Is it possible to push silent notifications (notifications without sound and badge) with Expo? I’ve been googling for a while without any luck…
If this is possible, how do you do it? Will this work even if the user rejects notifications?
Thanks in advance.
EDIT:
I’m sorry I was a bit unclear about what I meant with silent notifications. I basically mean a notification that the user never can see. I want this because of real-time updates without using sockets or polling for ex. But I dont want the user to get notifications when the app is closed because those changes arent that important, I just want to update in real time (without refreshing).
hey, you can make a notification without sound pretty easily:
const notification = {
title: 'This is a title',
body: 'This is the body text of the local notification',
android: {
sound: false
},
ios: {
sound: false
}
}
not sure what you mean about the badge. you can change the icon by setting an icon value inside android.
If the user rejects notifications permissions (at install for android and runtime for iOS), the notifications will not show up
I’m sorry I was a bit unclear about what I meant with silent notifications. I basically mean a notification that the user never can see. I want this because of real-time updates without using sockets or polling for ex. But I dont want the user to get notifications when the app is closed because those changes arent that important, I just want to update in real time (without refreshing).
// Stop here if the user did not grant permissions
if (finalStatus !== 'granted') {
return;
}
I wonder if we keep doing the rest instead of returning (so basically ignore user permission), does the app still receive notification? on OS level the notification wont show up since user has already reject allowing notification for the app, so does it turn into silent notification this way?
from my understanding, a silent notification is always delivered.
As a use case: If you want to implement SMS auth for login/signup, you can send a silent notification before requesting the SMS with the code. With that, you can verify, that a real device is requesting a code.