0

I need to send push notifications to thousands of users. But according to firebase documentation i can send only to 500 users at a time.

getMessaging().sendMulticast(message)
  .then((response) => {
    console.log(response.successCount + ' messages were sent successfully');
  });

I can handle upto 1000 users using this method

const registrationTokens = [
  'YOUR_REGISTRATION_TOKEN_1',
  // ...
  'YOUR_REGISTRATION_TOKEN_n'
];

getMessaging().sendToDevice(registrationTokens, payload)
  .then((response) => {
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });

Is there any other method how i can handle many users (>10,000) at a time ? Does sending messaging to topics can solve this issue ? Or it has its limitations as well

const message = {
  data: {
    score: '850',
    time: '2:45'
  },
  topic: "topic"
};

// Send a message to devices subscribed to the provided topic.
getMessaging().send(message)
  .then((response) => {
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });
Sudip Shrestha
  • 321
  • 1
  • 9

2 Answers2

0

One way you could do this is through setting a global variable for all of your files of a certain path and editing that global path instead of editing each and every other path.

Example:

Global js file:

global var path = "/EXAMPLE/PATH"

Specific html file:

<body>
    <script href = "PATH FOR THE GLOBAL FILE"></script>
    <script href = path></script>
</body>
Darrow Hartman
  • 4,142
  • 2
  • 17
  • 36
  • I don't think that would work in my case. Path might be different for different src. For example each img have different name, which basically means different src. – Sudip Shrestha Apr 06 '20 at 02:40
0

If you are using the Unix operation system, you may have both sed and find commands. Then just run in a shell:

for file in $(find .); do sed -i '' "s/\.\/app\.js/..\/app.js/g" $file; done

First, we loop through all files in the current directory:

for file in $(find .); do

Then we run replace command for each file, saying, to replace "./app.js" with "../app.js".

sed -i '' "s/\.\/app\.js/..\/app.js/g" $file;

You'll need to run it for every path you need to replace.

termosa
  • 661
  • 6
  • 9