Notifications are sent to a single device

26 views Asked by At

I have a button that calls sendNotifications, and this obtains the FirebaseRealTime tokenIds that are ExpoToken but when sending the notifications it is only sent to the same device, if I have 10 tokens, 10 notifications are sent to a device. What is my mistake. I'm with Expo and React Native and expo-notifications

const RTDatabase = "https://e......firebaseio.com/";
 const sendNotifications = async () => {
   somePushTokens = [];
   fetch(`${RTDatabase}/users.json`)
     .then((response) => response.json())
     .then((data) => sendNotification(data))
     .catch((err) => console.log(err));
 };

 async function sendNotification(data) {
   Object.keys(data).forEach(async (item) => {
     const pushToken = data[item].token;
     console.log("pushToken", pushToken);
     await Notifications.scheduleNotificationAsync(
       {
         content: {
           title: "Alert",
           body: "Thanks",
         },
         trigger: { seconds: 1 },
       },
       { to: pushToken }
     );
   });
 }
0

There are 0 answers