Can we use Server-Sent Events in an Ionic Cordova application?


#1

Hi, I am am trying to find out if the WKWebView (which I am using on iOS), Android web view, and also which ever web view the UWP windows build would use supports Server-Sent Events - I am looking for the most generic web push technology to use; and it must work for my existing Ionic application on all of iOS, Android, and Windows.

Thanks in advance for any info!


#2

What do you mean by that?


#3

So this is a server push tech. When I look at can I use it looks like iOS Safari supports it, and also UC Browser for Android. I notice Edge is under construction (didn’t see this before doh!!!)

Anyway, I’m just not sure (and finding it hard to find info on) how the above supports maps to the web views as we use in Cordova (Ionic)

Infact looking again at can I use, looks like web sockets has better support (so I again wonder if the web view will support this).

I am basically after server push, for data update notifications, so we can then call the REST api - rather than polling which I currently do.


#4

If you are using Cordova, this implies you are deploying your app on a native platform like iOS or Android. There multiple push providers exist that just can send invisible push notifications to your device. This technology is optimized for battery usage etc and should be used instead of any other manual solution.

But if you have to, the webviews are pretty close to the default mobile browsers. Most that works there, also works in the webviews.


#5

Yes I’ve looked at the push notifications such as Firebase cloud messaging, and would still consider this for more notification type of user messages, in particular if the app is not even running.

My service needs this api level immediate notification for not only my Cordova app, but other apps that also use same REST service as my Cordova app. These include a pure Web app, and also Windows services, and soon another Windows desktop app. The notifications need to be real-time, they just tell the app to then do a REST call to get new data.

I think the Web sockets may be looking the closest… I’ll need to see if this works for the Web views used by Cordova, and then how security etc also works. The service is asp.net so an option is Signal R, as this wraps a number of protocols, including Web sockets… Only restriction is this has only has client libs for Web and Windows (no mac or Linux)

I think I’ll just try it in a test app, that will soon show if we have support or not.