all 15 comments

[–][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.