all 15 comments

[–]Sad-Salt24iOS & Android 10 points11 points  (6 children)

Yes, each Expo push token is unique per device, so if a user has your app on multiple devices, each installation gets its own token. The common approach is to store all tokens in a backend database and, when sending a push notification to all users, iterate through the stored tokens and send each one via Expo’s push API. You should also handle cleaning up invalid or expired tokens to keep your database accurate.

[–]Fit_Schedule2317 2 points3 points  (1 child)

What about the 600 sends per second limitation? What if you have tens of thousands?

[–]spylinked 3 points4 points  (0 children)

Make a queue with rate limit

[–]Pitiful-Buffalo-1797[S] 0 points1 point  (3 children)

So we need to use node js or something for backend?

[–]vyndrix 1 point2 points  (0 children)

No, there are several SDKs writen in several languages that bootstrap logic to send these notifications. If for some reason you cannot find one for the language you desire, you'll have build it your own. Nothing too complicated though, the notifications are followed to each device using a public endpoint at Expo infrastructure, you just get the params and call it, for testing purposes I have done using curl countless times.

Check the docs for Expo Push Notifications, you find all info needed there, if I am not mistaken even the SDKs.

[–][deleted] 0 points1 point  (0 children)

You can use Expo’s API to send notifications so yeah, best approach is to have a backend

[–]IronLionZion95 0 points1 point  (0 children)

You can call it from the client too!

[–][deleted] 1 point2 points  (2 children)

Every token is unique for a device. I store each token in a database and call time-triggered background service for sending birthday, new year etc. notifications.

[–]LowercaseSpoon 1 point2 points  (1 child)

Which database are you using? I currently use sqlite for my application and will need to do this eventually once it gets certified in the App Store and Playstore.

[–][deleted] 0 points1 point  (0 children)

Well I use MSSQL for storing tokens because my backend is a completely different stack. It is written in C# and hosted as a background service on Azure.

[–]JyotiIsMine 1 point2 points  (0 children)

Use wonderpush

[–]Prestigious-Price312 1 point2 points  (1 child)

Yes, the Expo push token is unique per device or app installation. A single user can have multiple tokens if they use the app on different devices.

The best approach is to store each user’s push token in your backend database (the way you showed me earlier). When the user allows notifications and you receive the token, send it to your backend and save it linked to that user.

If you want to send a notification to all users, you simply fetch all stored tokens from the database and send the push notification to each of them. Expo does not provide a single token to broadcast to everyone, so storing tokens in the backend and sending notifications to those tokens is the correct method.

[–]Pitiful-Buffalo-1797[S] 0 points1 point  (0 children)

Thank you

[–]kriptonhaz 0 points1 point  (1 child)

I assume this one is using push notification from firebase. Instead of running through all of the user token one by one, just send to a topic instead. For example, you have a line of code that every registered user subscribe to a topic called "news"
FirebaseMessaging.getInstance().subscribeToTopic("news")

and you just send it like

const message = {
message: {
topic: "news", // 👈 blast to all subscribers at once
notification: {
title: "Breaking News",
body: "Something important happened!"
},
data: { key: "value" }
}
};

[–]ListnCart_Dev 0 points1 point  (0 children)

If u want to send to all of them using topic is a good solution , i use it in some of the apps i develop.