3

I'm creating an iOS app that relies heavily on user interaction with notifications. When the user interacts with a notification, themselves and their followers will be notified immediately.

For this, I've decided to use Firebase Cloud Messaging, since I'm already using other Firebase services.

My app server is written in TypeScript using Node.js, and node-xmpp-server. According to the documentation, there is no FCM Java SDK, so Node.js was the logical choice.

When my server is run, it creates a Client and listens for incoming stanzas from FCM. Something similar to this:

var Client = require('node-xmpp-client')

var client = new Client({
    jid: 'user@example.com',
    password: 'password'
})

client.on('online', function() {
    console.log('online')
})

client.on('stanza', function(stanza) {
    console.log('Incoming stanza: ', stanza.toString())
})

For the entire server, there is only one Client that listens for all incoming stanzas form FCM.

I have so many questions that I wasn't able to find in the Firebase documentation.

  1. Will simultaneous stanzas come in to my server? Or will Firebase ensure only one is sent and handled at a time?
  2. If simultaneous stanzas come in, what happens? Will some get lost?
  3. Do I need to restructure my server to handle simultaneous stanzas? If so, how do I go about doing that when all I can do with FCM is listen for stanzas?

Thanks!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
cohenadair
  • 2,072
  • 1
  • 22
  • 38

1 Answers1

1
  1. You will receive simultaneous stanzas
  2. You should process them and ack them
  3. Yes. You need to use multi threading, like 1 thread is receiving the messages and another (or more than one) is processing them and enqueuing the ACKs. How to do this depends on your library / language.
Diego Giorgini
  • 12,489
  • 1
  • 47
  • 50