Webrtc sending call offer over FCM - push-notification

I want to send the call offer message (sdp) over fcm to offline users. But the issue is the limit of fcm is 4096 bytes and the sdp of call offer exceeds this limit in case of video calls.
My mechanism for call offer: User creates a call offer message for remote peer, get the message and emit it to server via SocketIO. Server then checks if the remote peer is online (connected via socket).
Now if the remote user is offline I need to send the sdp to the user via push notification.
Is my approach to this problem correct? Or do I need to change the mechanism to first signal the call offer and then when the remote user get notified, I generate call offer and use my SocketIO to transmit the sdp

Or do I need to change the mechanism to first signal the call offer and then when the remote user get notified, I generate call offer and use my SocketIO to transmit the sdp
I would suggest the above approach instead. Use the push notification to "wake" the remote user (callee) and make them connect via SocketIO. Then, make the caller generate the offer SDP and send the SDP via SocketIO to the callee.

you can reduce the amount of information with some of the techniques described in https://webrtchacks.com/the-minimum-viable-sdp/
Given that the information in the SDP is somewhat time-critical a small push notification and then fetching the full SDP from your local server is the better approach.

In case of iOS, You can use VOIP notification. Also you need to increase VOIP push notification size while sending the notification from server side(e.g. java).

Related

iOS Apps that access the same BLE peripheral: How to distinguish?

I have to following scenario:
My app requests and receives data from an BLE peripheral (a glucometer). It it possible that the user has another app (from another developer) installed, that also communicates with the peripheral. I noticed that my app receives characteristic notifications for requests that where initiated by the other app. This causes my app to receive some data twice.
Is there any way to distinguish between responses to my request and responses that are caused by another app? Or how can I handle it?
While the stack obviously knows which app a certain (read, write) response belongs to (because there may only be one pending request, and it knows who sent the request), there is no logical or sound reason why it should dispatch a notification to a single app (among those who have enabled notifications).
Note that the GATT specification does not define "multiple gatt clients per link", there is only one client, so the peripheral doesn't even know there might be two apps talking to it. Hence when it sends a notification, it doesn't include a "target app" field.
The feature of multiplexing multiple apps to the same GATT connection is something iOS and Android teams etc. came up with.

AMQP, RabbitMQ Push API how works?

I'm trying to get a deep understand how works the Push API communication between the client and the RabbitMQ server.
As I know - but correct me in case - the client open a TCP connenction to the broker (RabbitMQ) and keep this connenction alive until the client decision to close it. But during this connection the client can get messages immediately.
My question is, during this connection, do the client monitor the Broker to ask him for messages, or when the Broker forward a message to the Queue, where the client subscribed, just take that connencion and push the data to the client?
first case: client monitor the broker for messages
last case: client don't need to monitor the broker, broker just push the data
or other?
There are two options to receive messages
The client registers a consumer callback (basicConsume) on the channel; the broker then "pushes" messages to the consumer.
The client sends the broker a basicGet and receives one message (if present).
The first use case is the most common.
Since you tagged the question with spring-amqp I assume you are interested in Spring. For the first case, Spring AMQP has a listener container (and #RabbitListener annotation); for the second case, one of the RabbitTemplate receive operations can be used.
I suggest you look at the tutorials to get a basic understanding. They cover several languages including pure java and Spring AMQP.
You can also look at the Spring AMQP Reference Manual.

Is it possible to broadcast messages in a production PWA using FCM for Web without having a dedicated XMPP server?

This is an architectural question. I haven't implemented FCM yet, but as far as I understand someone needs to deploy an XMPP server in a real world scenario which provisions the inventory of the registered device tokens.
In my use case I'd like to just broadcast short messages about important update information, like "XY presenter's session at 15:00 got cancelled" and I'm not interested in the device tokens. My application is a Progressive Web App, so I would use FCM for Web.
The demos I saw so far showed a client receiving the device token, then that specific device token was picked up from the debug environment and used to send the demo message to the client - thus bypassing the need of a deployed stand-alone XMPP server, but just for demo purposes.
I'd want to avoid the use of an XMPP server, I'm not interested in dealing with the device tokens at all - if possible. Firebase's FCM/GCM server have them anyway. My plan is to pick a single topic name for that channel (the only topic what my app would use actually at this point), and push messages to the devices who listen to that topic. Is this a viable plan? I haven't found any mention of this whatsoever. Firebase knows all the tokens internally and it would make the architecture simpler if I don't have to deploy a server.
I don't know how the decomission/expiration of the device tokens would happen on Firebase's side, but that's another issue I'd have to deal with if I'll run my own XMPP server and provision tokens.
To send messages to a device (so-called downstream messages), you need to specify the server key. As its name implies, this key should only be present on a server or in some other trusted environment. So to send messages to devices you will need to run code in a trusted environment.
The server doesn't have to speak the XMPP protocol however. You can also just use HTTP to call the FCM servers. But a server will be needed, simply because sending downstream messages can only be done from a server.
For a simple example of sending device-to-device messages with this approach, see my blog post Sending notifications between Android devices with Firebase Database and Cloud Messaging. It's about Android, but the same approach of using the Firebase Database as a message queue will work across all platforms.
The tricky bit to map will be (as you already mention) the fact that topics are not available to FCM for the web yet. Last time I tested, you could call a server-side end-point to subscribe to a topic, like described in this answer: GCM: How do you subscribe a device to a topic?.

How Push Notification Services really work?

I am trying to understand how exactly push notification services work.
Are these real push services with constant connection to server or just mimics by polling?
How does a server with heavy traffic maintain so many connections?
In general push notifications work both by establishing a long-lived TCP connection, or using long-polling. The maximum number of connected clients is determined by the server resources.
Take a look at the Socket.io protocol stack for an example. Or better yet, at the XMPP/Jabber protocol, which relies on TCP principally and falls back on long polling.
Fusio is correct. For mobile phones, a single push service is typically used (Google cloud messaging for android, Apple Push Notification Service for Apple/iPhone) to limit the amount of connections from the phone. 3rd party applications register to these services and push messages through them.

push notification explanation

What are push notifications and how do they work? Also what is the difference with googles cloud to device messaging? Is c2dm also a push notification? Also do I need Special server setup to implement push notification?are push standard or every device has different implementation?
Basically the server maintains a list of connected clients. Whenever something of interest occurs, the server sends the data/notification/updated state to the connected clients. This is in contrast with pull, where the clients poll the server for changes.

Resources