matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

Push notifications

Open Christilut opened this issue 7 years ago • 8 comments

I'm trying to figure out how to get push notifications working. It is my understanding so far that the client decides which Sygnal server to use, but I can find no reference to anything related to Sygnal or push notifications in the SDK.

Does the JS SDK support this? What is the suggested way to get push notifications working, if possible at all?

Christilut avatar May 23 '18 12:05 Christilut

Push notifications are currently not supported.

krombel avatar May 28 '18 08:05 krombel

Would it be possible to run the sync command inside a serviceworker and display a notification from there? That seems like the easiest option, if possible.

Christilut avatar May 28 '18 13:05 Christilut

Sure is possible

t3chguy avatar May 28 '18 13:05 t3chguy

Hmm I tried to get this working but BackgroundSync wouldn't update the matrix client. Creating a backend solution for push notifications now, and maybe abusing some Synapse endpoints to get the right information.

Christilut avatar Jun 01 '18 08:06 Christilut

I have a standalone Matrix Synapse deployment and a custom Push Gateway (my own service) how do I tell Synapse to use my gateway?

I thought it was done via this SDK.

oliverjanik avatar Sep 24 '18 06:09 oliverjanik

the SDK is meant to have a constant connection to your server via a /sync poll loop. So notifications would be calculated that way. As you have a constant connection, you have no need for a dedicated push gateway. And therefore you cannot configure that

krombel avatar Sep 25 '18 10:09 krombel

Found it: http://matrix-org.github.io/matrix-js-sdk/0.11.0/module-client-MatrixClient.html

There's a setPusher method, which is very poorly documented. The parameters it takes are described in the protocol spec here: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0- pushers-set

One of the args is the gateway URL. So obviously @krombel obviously talking nonsense.

When I run this in cordova the user can kill my app any time. Same thing in the browser I want to notify users via webpush or APNS or GCM.

All of this are legitimate use-cases.

oliverjanik avatar Sep 25 '18 11:09 oliverjanik

Ohh. Sorry... You are right there is setPusher(pusher, callback) which accepts a pusher object as defined here. I was referring to Riot which does not implement some push API but uses an ever running /sync loop. And because it is not used there I somehow thought it is not part of the underlying js-sdk... Thanks for proving me false @oliverjanik. I have simply not thought of that possibility...

krombel avatar Sep 26 '18 11:09 krombel