4

What protocol is used for mobile push notifications?

Take android as an example. First, make a HTTP request from a third-party server to the Firebase server. The question is next. How does the FIrebase server select the required mobile from many and send push notifications?

Of course, I know I can send push notifications without worrying about that. However, I am curious about interest.

On TCP / IP, IP address and MAC address are required for communication, but how do you send push notifications to mobile?

Links used for studying

thanks.

fsk5304
  • 395
  • 1
  • 3
  • 11

1 Answers1

12

On iOS, when an app registers for remote notifications it receives a token. Apple stores this token against the device's actual unique identifier in their database.

The iOS device itself maintains a persistent TCP connection to Apple's servers on port 5223. The protocol itself is proprietary to Apple.

When a push notification is sent to Apple's servers, they cross reference the token specified in the push to determine the actual device that the push is for.

The notification is then delivered to the device on the already established TCP connection.

If the device isn't currently connected (say it is in Airplane mode) then the payload is held until it reconnects or the message is discarded for being too old.

I imagine Android would work much the same

Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • 3
    This is exactly the answer I was looking for. Thank you very much. I have a few more questions. Sorry for my lack of knowledge. ①The device itself maintains a TCP connection permanently. Doesn't it cause unnecessary communication and battery use? ②If an application that uses multiple push notifications is installed on the device, are the number of TCP connections maintained for that application? – fsk5304 Nov 28 '19 at 04:34
  • 1
    ③When returning from airplane mode, will the mobile re-pay a permanent TCP connection to Apple's server? In that case, if the application is not running, I feel that the TCP connection is not established. I'm really sorry again and again. Thank you in advance. – fsk5304 Nov 28 '19 at 04:34
  • 2
    The iOS device tries to remain connected. When it comes back online it makes the connection. It is nothing to do with any app that may or may not be running. The connection is made by a task within iOS itself – Paulw11 Nov 28 '19 at 04:43
  • Thank you very very much! ! Your answer made me happy. – fsk5304 Nov 28 '19 at 04:49
  • 2
    Sorry, I missed your first two questions. 1 - maintaining a TCP connection requires an occasional keep-alive, but in general doesn't use a lot of power. The amount of data actually sent for a push is quite small. The phone is performing together periodic tasks on the network and I am sure Apple tasks advantage of the radio powering up to perform many of these tasks at that time. 2. Only a single connection is required as notifications are not delivered directly to apps. iOS receives and processes them – Paulw11 Nov 28 '19 at 10:18
  • Thank you again. That is exactly what your answer was looking for. Why are you so detailed? If possible, I would like to be your disciple and learn from you. Thank you very much. – fsk5304 Nov 29 '19 at 00:12