Does FCM (web) use WebSocket for the recipient of messages? - javascript

i just wonder how the "FCM" realy works on the web.
does it use websocket ,or it's a built in feature whit in
browsers (chrome,firefox ,...)

FCM (Firebase Cloud Messaging) uses HTTP and XMPP Server Protocol serving JSON and Plain Text both.
FCM Server Protocols
Currently FCM provides these raw server protocols:
FCM HTTP v1 API
Legacy HTTP protocol
Legacy XMPP Protocol
Your app server can use these protocols separately or in tandem. Because it is the most up-to-date and most flexible for sending messages to multiple platforms, the FCM HTTP v1 API is recommended wherever feasible. If your requirements include upstream messaging from devices to the server, you'll need to implement the XMPP protocol.
Please visit About Firebase Cloud Messaging Server | Firebase for more details,https://firebase.google.com/docs/cloud-messaging/server#choose. Hope it helps.
How exactly are web push notifications delivered to a user's device?
There are three actors involved with delivering a web push notification, along with a fourth, optional, component for advanced functionality.
Web Push Notification Service: Each browser, including Chrome, Safari and Firefox have their own notification delivery service. Chrome uses Google Cloud Messaging (and now Firebase Cloud Messaging ), Safari uses Apple Push Notification Service (APNS) and Firefox uses MDN servers.
Service Worker Registration: Developer must register the service worker on the browser. This is only for Chrome and Firefox. Safari while has added support for service-workers, Safari notifications are delivered using a different mechanism.
User’s Subscription ID: Subscriber ID is generated when a user opts in to receive notifications from a specific website.
Additionally an SDK (OS client library Software Development Kit) can be added to a web app for extended segmentation and analytics capabilities.

Related

Can Firebase Messaging Service be a scalable replacement to websockets / server sent events?

I am developing a webapp and currently my app server uses Server Sent Events to maintain a connection to the user to efficiently push things like new messages and other events to them without them having to constantly poll the server to ask.
I'm looking for a way to implement Push Notifications such that I can use the Notification Web API to deliver notifications to the user either when they are in a separate tab, or when they have it running on their phone and they have Chrome minimized.
After some research, it looks like Google Cloud Messaging has been replaced by Firebase Cloud Messaging, and this is the recommended service to use to deliver push notifications. It looks like it works by having the user maintain a persistent connection the Firebase Servers and your personal app server posts requests to Firebase for them to deliver to the user.
My question: does this alleviate the need to implement and maintain an SSE / WebSocket server? I'm wondering if I can't just forward all my events through FireBase instead and have them be delivered to the user via their service. That is, I would have two classes of messages both sent from Firebase:
One would be the typical "notifications" which are interpreted as such by the user (such as a new message), and require local permissions for the Notifications API. And then the other type would be other "real-time" updates that wouldn't require a notification (such as a message being edited, or the "user is typing a message" prompt)
Is this sort of thing possible / recommended, or is my understanding flawed in some aspect of this?
Nothing you're describing seems outside of capabilities of FCM.
It looks like it works by having the user maintain a persistent connection the Firebase Servers
Actually, it's not the "user". It's the messaging infrastructure provided by the device. For Android, the message get routed through Google Play services, which runs as a privileged process in the background. For iOS, messges go through Apple's APNS. These components maintain an open socket to their respective services, and they're more effective than the app managing the socket on its own, because the app can't manage a socket in the background indefinitely - the OS will shut it down after some time. This means the app can wake up and receive messages soon after they're sent.

Is there a way to send firebase web push notification from the firebase console

I think the firebase console can only send notifications to android and IOS app not to web browser, is that correct?
The Firebase Cloud Messaging (FCM) supports Android, iOS, and Web apps.
The FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API.
Here's the official document.
But you have to know that some browsers doesn't support Push API.
Can I use: Push API support

What is the differnce between Service Worker and GCM

I am really confused about the two technologies GCM and Service worker. We can use both for push notifications but the service worker are specifically for browser push notifications and GCM for mobiles. This is my theory about the above mentioned technologies. If i wrong then please share your valuable suggestions and give me a right guide.
Service Worker
A service worker is basically a special javascript environment, that runs in the background of browsers. Websites can register service workers and then they can run some code in the background.
GCM
Is a product of Google, which basically provides a server API for sending messages across devices. If you combine them with a service worker, you can send notifications to Chrome whenever you want (if the user allows you to register a worker).

Secure communication between Chrome extension and mobile over local network

I am developing a mobile application and a corresponding chrome extension and planning to use UDP for data communication between mobile and extension using the udp API provided in chrome
It seems there is no provision to use DTLS in chrome APIs , so I a wondering how to secure the communication.
If I decide TCP over UDP I think TLS can be used for security as per the documentation
The mobile app and extension communicate only over local network.
Thanks in advance for suggestions.
To begin with: Extensions cannot use sockets APIs. Just so that doesn't come as a shock later. Only Apps have access to that.
That said, the sockets API provide you access to raw sockets. That means you can implement your own security on top of it. The API method you quote is there for convenience, but it can be reimplemented.

how to connect with azure service bus topic with javascript

I am creating a mobile application with cordova(phone gap). I would like my app to talk with an azure service bus to post messages to a topic and read messages from a subscription.
I have found all kinds of details on how to do this with c#, java, python, node.js. However I haven't found any details on how to do this with pure javascript.
Is this possible? or must I use Azure mobile services and configure it to communicate with the service bus?
CORS - Cross-Origin Resource Sharing is now supported in windows azure for storage ,table and queues. So you access the REST api of these from javascript. Topics and Subscriptions are not mentioned here though. http://msdn.microsoft.com/en-us/library/windowsazure/dn535601.aspx
Also if you have not already check out Azure notification hubs which may help in your requirement. But mostly for notifications to cross platform devices.
You can use REST API to enqueue messages to a topic: http://msdn.microsoft.com/en-us/library/windowsazure/hh780786.aspx
Microsoft provides Service Bus REST API
https://msdn.microsoft.com/en-us/library/azure/hh780717.aspx
Microsoft provides two ways to authenticate
1. Azure Active Directory (Cordova project sample that uses AD)
2. Using certificates
If you want to do it using certificates, you need to generate the .cer and .pem files and upload the .cer file to your Azure portal -> Settings -> Management Certificate
You can then trigger a http request by passing your .pem file to authenticate your application

Categories

Resources