Search code examples
androidcordovaserver-sent-events

Server-sent events (SSE) and Cordova / Phonegap


I want to implement an application where a user receives a notification when some other user has done something. I don't want to user Push Notifications for that, because this information is only relevant, when the application is opened.

I thought of using Server-sent events. According to caniuse EventSource is not supported on Android lower then 4.3.

Does anyone know something about the support of this cool feature in Phonegap / Cordova? Or a plugin which provides this functionality on Android as well? iOS seems to be no problem.

I'm using Cordova 3.1.

Thanks!


Solution

  • You can have a look at this EventSource polyfill library: https://github.com/Yaffle/EventSource

    It's only supported on the Android browser (lower than 4.3 at least) if you add 4k of padding after each message. Perhaps you can also try implementing long polling? It might be a better solution instead of eventsource with 4k padding.

    You can read more on this topic here: https://github.com/Yaffle/EventSource/issues/14