So, we are going to talk about push notifications on mobile and unified push, and we are
Daniel and Simon.
Daniel is developing the XMPP client conversations that can be used to get push notifications
with unified push.
And on my side, I've started the project like five years ago, and I developed a development
and then there are libraries and some applications.
Yes, awesome.
Let's start this talk by asking ourselves the question, how do notifications actually get
to my phone?
How can my email application know that I have like new email and notify like tell me or
the user about it?
So, the easiest approach to this is like ask the server if there's new email in like periodic
in top of like every 15 minutes or so.
And this is basically the approach that pops free back in the day used.
And can I get a quick show of hands on how many of you have been around for long enough
to have fetched the email of our pops free?
Who still fetching the email of our pops free?
Okay, two, three, very brave people.
Thank you.
So, yeah, like the diagram shows, every 15 minutes or so on set interval, I'm going to ask
myself, is an email and a lot of cases you're going to say, no, you don't have any
new emails and then occasionally server goes, oh, you have no emails.
And there are a lot of pros and cons to that approach.
One obvious pro is that it's like very easy to implement.
But the downsides are that it's very expensive.
Like the flow chart I showed you like didn't even show like the whole things that usually
you don't just ask for like new emails.
You also have to like establish a TLS connection, hopefully, before and then you have
to lock in and stuff like that.
And just as far as the user visible notifications, our concerns might be like a
high latency, right?
Because like if you're asking every 15 minutes, you might have to wait like 14 minutes
on and 59 seconds at the worst case to get notified of an email that just arrived shortly
after the last time you checked.
And yeah, and also like the vast majority of connections will be like unnecessary
because like unless you're like a very important person, like a lot of like those checks
you're just not going to have like new emails.
And then there's the more modern approach that IMAP uses these days, for example, where
you build up like one connection maintains the connection for as long as possible.
You establish TLS ones, you authenticate ones and then you're just going to like instruct
these server to give you over the existing connections like a short shout out is there's
like new emails.
So you just maintain the connection, wait and then occasionally the server's going to tell
you that says new email and again that's how IMAP works.
And yeah, so the zero behind that is that network connection that doesn't do anything
doesn't actually consume that much of a power, right?
Because like your mobile, your mode, then it's going to go into like power saving mode and
like yeah idling doesn't do a whole lot on the modem side of things and also on the
operating side of things.
It's just like a few bytes in the kernel somewhere reminding you that there's a connection
but like nothing actually going to be done.
That's that's a series, but in practice unfortunately it isn't that simple because of like
next and weird networking situations.
You have to do like period of things to check if the connection is still alive, you have
to read doubly see connection entirely if you switch from like Wi-Fi to mobile or if you
went to airplane mode for a little bit of time or draw through tunnel or whatever.
So you have to like manage the connection, it's not just a state of connection and that would
be theoretically fine but if you have multiple apps running on your phone then this thing
is not like not synchronized across apps like various apps will ping at various intervals
or do the reestablishing light, one will do it like slightly later than the other one and
this goes against the principle of the principle of power saving that says like transmit
as early as possible and when you do send as much as possible at once but it's basically
like power managing trick for your modem and this also can be done in like the management
can be like messed up a little bit like it's it's difficult to like implement correctly it's
it's a bit not not more science but yeah you have to like put some sort and effort into it
and like for example if you are comparing signal which is directly connected to the signal server
like so signal in mode where it doesn't use Google push notifications but like tries to maintain
the connection to the server directly if you compare that to conversations on next
if you decline doing the exact same thing we can see that like signal is doing a worse job
at the same task right and like obviously the signal developers very likely on stupid
anything but it's just a show that you have to like put a lot of like effort and dedication
into like managing this this connection properly yeah and just all kind of like raises a
question can be it not simply combine this maintaining of like one connection into like one
app like have just maintained one connection to a server somewhere and have that connection
being managed properly and yeah the answer is that's basically what a firebait cloud
messaging is or what Google push is and then I very deliberately use like proprietary
services on one hand like for example we have like FedEx which like wants to notify
my my FedEx mobile app that like I don't know my delivery has like an update or whatever
and then the service like FedEx upcoming that example will tell over like a proprietary
API will tell the Google servers the Google servers will over that over one persistent
connection tell what's got the play services like a background service that's running on like
most Android phones will tell that and then the app will wake up the play services will wake up
the app that that should receive the notification and yeah same thing if like for the
love times that app if our flight gets later whatever it all gets pushed over that one channel
and yeah so as I said like the replay service is maintained like one persistent well managed
connection to Google servers but there's like it's a good implementation of like that problem
but there isn't any like magic behind it it's just like does he kind of opinions you reconnect
and all that it's just like implemented well and relatively efficient and then
yeah the correlation between like which service and one supposed to which app
happened over like so-called tokens and it's used for like the correlation between
the servers and the app and yeah by default if you just buy like a stock
Android phone somewhere yeah a very few things work without Google push like for example
apps that wanted to maintain like their own persistent connection would need explicit user content
and there's like a annoying proper notifications and also if you want to distribute
the apps through the Google Play store then it has like additional limitations on top of that
where like only certain kinds of apps are allowed to maintain their own persistent connection
like for example like instant messaging app but like your game or whatever probably wouldn't be allowed to
to have that yeah and there's obviously like a lot of like criticism uh towards Google with
regards to like the enforcement of every app having to use like Google push notifications
so one of the arguments is yeah Google just wants total control and I guess there's probably
some truths to that but also as I showed earlier like implementing like push notifications
yourself isn't like completely trivial and you don't want to like burn like every developer
with that and then uh like on the on the app side like in some case or in a
lot of cases Google doesn't actually see any content because in a lot of cases it's just like a
wake-up signal and like a dumb wake-up signal that doesn't actually tell you anything
or for example it's a signal case just all we have like something happened there are new
notifications that there's like not the actual message content in there so it's not as worse as some
people say this but yeah it's certainly not good either and it's usually type to your Google account
and there's also like a whole lot of more criticism with regards to Google push that we don't have
time to go into but if you don't have the slides you can have a look at like a lot more arguments
to that slides are linked in the or only for them perhaps that by the way
um so yeah this raises the question uh can we not have the same thing but like open source
and different for last and uh yes we can and um that's uh unified push so uh the the the graph looks
very similar to the one I showed you earlier uh except uh is this time I used like open source
services I used like master don't as an example and and fast millers a nice email provider and then
like open source apps tasky that's a master don't client let us that's an email client and um
so in this graph you're going to introduce like the the solid lines are like what what's going
to be like a centralized protocol and then the dotted lines are like proprietary things and like
in the uh unified push uh mental model the place services the thing that runs on your android
basically replace with something that's called like a distributor and um there are various implementations
for distributors and then every uh distributor goes along with like one particular implementation
not one particular instance but one particular implementation of of a push server uh and that's
because like the the protocol that the distributants push server are talking to each other that's like
like not standardised uh exactly but but what is standardised is the communication between the
apps that once they use unified push and the distributor and um between like the service and uh
what I called the push server that's both standardised and on the android sites is uses just standard
android interprocess communication like broadcast intends they are called if you're familiar with uh
android development and on the other side on the service to push so what we use like a fairly well
established um internet centers called web push which is also what um website that wants to like send
push notifications through a browser which use uh that's basically yeah that's the things that like
all browsers implement these days and it's like i test standards like various um there is iFCs and stuff
and through the fact that it's like a well established web standards like a lot of lectures out there
because due to the fact that they want to create uh notification in the browser already have support
for that push like for example like master don't already have support for that and um yeah they're also
like other uh things that already have support for it for for example jamep which is like a modern
dairy placement for i-map and uh calda and calda and stuff like that natively comes with web push support
and then there are extensions to like even some areas like iFC to trigger uh web push notifications directly
and like even if the service you want to talk to doesn't uh yet support that push that's uh
web push is still actually most likely candidate uh to be like adopted by them so for example there's
currently talks on to like retrofit that push into i-map that's so even if you're using an email server
uh that uh doesn't the web game of all whatever then you could potentially uh still negotiate
like uh web push with an i-map server and again not synthesized this uh what's being talked
between the district attorney and anti-push server um yeah and the redistributor basically does
the managing of a persistent TCP connection that i'm better talked about uh earlier and um
unified push actually has like a variety of um distributors to choose from and yeah this kind of
like establishes a little bit of a competition between the uh different um uh between the
different distributors on like who can manage the connection like the most efficient way or whatever
and like various uh distributors use there is protocols to talk to their respective um push server
so web sockets is used a lot as these days but uh uh servers and events like events or CHDP
long polling sing is used by some of them and um we can also use something like xnp which is what
uh conversations does uh and yeah xnp also like very efficient and very good at like uh it's
establishing a uh good quality permanent connection that doesn't consume a lot of resources
and yeah this is a graph on uh how likes entire process what work and again uh the solid lines
are like what's standardized and the dotted lines are like then what um the various
where the various services are have like uh their own proprietary protocols find so tasky again
that's like a uh a method on app what uh center registration request to the distributor um
and then the distributor would go talk to the push server and try to register and get like a
that push URL uh back like that pushes just like that's in HDP URL uh get that back to the distributor
over whatever like protocol distributor and push server have in common and then the distributor can
tell the um the app in question like uh tasking this example oh here see the URL and then
tasky or any other again uh uses the the uh that push end point and and hands it over all the
way to the to the service and that's like the one time registration that you do one time like
really you first set up your account in tasky or when you first open the app or whatever and then um
here again if then Macedon or whatever like actually wants to like notify me of a new boost or like
or like a new direct message I got in it would over um web push tell the push server over the
URL then the push server would over the established communication channel uh tell the distributor
and then the distributor would send uh again and that's again something to size because like
um tasky is the support that would send a broadcast intent Android IPC thing to tasky with the
contents of the push notification and yes if you want to try it yourself um a very quick and easy way
to uh get started would be to pick the distributor uh son up um for people who are very keen on like
hosting the push server part of that um themselves uh notify and next push thing I think that
are a little bit obviously you can sell for all of them but like so as the ones that are like um
very easy to set up next push kind of like works with the next cloud uh instance that some of you
may or may not have so if you already has that like go for that and if you are already uh a job
of an example user or uh want to become one and use that for like you know further rated
instead of messaging needs same conversations uh can also act as a distributor and and use the
example pick connections that um conversation already holds in the background uh to also fan out
push notifications and yeah on the app side of things there are actually already like a lot of
apps that uh support unified push um so yeah there's a lot of like mastered on apps uh tasky fatty
lab uh but there's also other interesting apps like for example duff x5 that's a calendar card
depth synchronization thing um then letters that's an email client which is a jammer protocol
fan x that's the uh don't want to say open source version of firefox but the more open version of
firefox that's distributed uh via android for example that actually has um unified push support
internally and then then molly that's uh for walk of of signal has support for um unified pushes
well and there are a lot more apps and you can find them on our website and and browse through them and
yeah and maybe it's coming like is it to your app like the app you are developing um or like an app
you're using because it's uh it actually makes life for app developers a lot easier because they don't
have to maintain it complicated like permanent connections themselves and but uh uh unified push itself
is like very easy to implement uh for the the apps uh apps side of things that's basically like
library that does all the the IPC stuff on android that's called the connect a library uh you could
technically if you're like a little bit more familiar with android development issued the uh broadcast
intense and stuff all yourself um or you can connect a library whatever you prefer and on the
server side of things if you're not using like masterdom but are writing your own server for like
whatever um then there are already like a lot of like that push libraries out there because again
like that push is a big established standard for browsers and like if you have some sort of server
thing that wants to interact with your app then yeah lots of library support for that as well
and yeah because this is like uh frost on mobile and and android is increasingly turning
the not frost way unfortunately I also want to briefly mention Linux on mobile and uh unified push
does actually have a debust API that's specified like the same kind of like interactions that I
described to you earlier um this far there aren't that many implementations is on the distributor side
on the app side of things of these unified push debust API but yeah I'm personally interested in
in working on that he's probably interested in working on that and a lot of the
experience that we gained with like implementing that uh for android is like very likely to
transferable to the to the Linux side of things as well and yeah a lot of shared knowledge lot of
gained experience can be um put into these a little of some mobile and select debust thing as well
and yeah I'm now going to turn it over to the 7 for the quick down
so yeah let's see oh it works
so I've my my phone there and um I have a distributor which is a snap
already installed
and for the example that we use uh six ampere up so I just have to register
yeah I can choose which distributor I want to use and which one we will be my default one because
I have many of them and that's it I just get an end point where which can be sent to my server
that will be available to send to my mobile mobile phone so if I send a notification we can see
that are received one um which will be more interesting is if we send it from another application
or another device if you want you can test it and just send a random message and I should
be receiving I should receive them on my phone
so
and what are content
and when these uh I think the content has a notification so you can see them
but I receive many of them
okay so that's it's sorry
and most important if you have questions
and it will need the permissions to uh which permissions needs the distributor to
run on the device and basically it will need two permissions one to show a notification
which is required to get uh four guns service and the permission to run in the background
visit a teamyzish
yeah try this a question so uh deal with the server to distribute messages just to be
the bottom of the stations would be an interesting for the uh uh three-letter agencies
it would be interesting to be hacked in etc so I do uh how in power included the notifications from
the uh from the providers to up to the phone is there an encryption or is it uh
included in cryptics by the server etc so the question is as the person notification
encrypted and yes there are encrypted following the RFC 82 91 which is the web push on
encryption are they encrypted from the from the application server to the device to the
phone or can I yeah so yeah I think quickly go back to the so there's basically like two
encryption's going on so if the uh Macedon server is sending like a push notification to our
task is it actually has a actually has content because like a lot of push notifications are just
wake up signals that don't have any content but like in the Macedon example there's actually
any content in there the Macedon server can basically do like enter an encryption to the app
we're only the app has the um private key to decrypt that right and then there's like another
layer of encryption on top of that or beneath that if you will then the communication between
the distributor and the push server is usually like TLS encrypted and stuff of that that's how it says
is there a coupon you could write a distributor yourself it doesn't do that but like
the distributors I listed they are used either like HTPS for the ones that use like web
sockets and stuff or um the one that uses XMP obviously also uses TLS because like TLS mandatory for
for XMPP okay so the only thing that push server or C is that the Macedon has sent an
notification to you yes the only thing uh the push server C is uh from whom to whom basically so
that something goes from master down to to to to nap but yeah obviously the goal is also I mean you
can self-help the push server right so the push server is very little but you can also sell
for us or put it like to a trusted party yes is there any delivery success reporting you can check
when the notification was received or not so web is there a delivery notification for the push server
yeah success reporting um the RFC 8030 web push or RFC define a way to to get this report
but we don't see any push server doing it right now uh made me the Mozilla one google one or any
other implementation but usually when your application receives the notification it's kind of to a
request to your own server so this is the way you do
it's not I try to implement it and I will see notifications only what's on the side right is the
app expected to stay running in the background and we'll get sure it's on the location um even on a mobile
phone uh the application can be started from the push notification but for if you shut doesn't implement
it yet I'll just have to like three three lines of code to do because it has been a really
recent version of the virtual library it's started after a restart of the phone do we need to restart
the distributor and no there is a different way to start automatically your application when the phone
puts
the question is the is the service on mobile phone unlinics mobile phone
origin start and does it need to run as a system and today the service isn't
started by default but so you can install on the most Linux distribution and it runs as a user service
in fact my question is in the card below but to my knowledge there are apps like
signal apps and others when they are installed they check in the have access to the
group names are received and if they don't have access to this they will manage themselves
the issues with the way you just show us with a little battery clean and so
and what what my knowledge when this first choice is done in the app after that is that I do
certainly are you allowed or integrate the real businesses the app will remain on the first
choice and so the question would be between of your android one suddenly
installed and not on the internet in the file push would be apt to be capable of suddenly choosing
to go on mobile phone push or you have to read on the left means toilet so the question is
are you able to use unified push after using your own application if you install the service
and you did the example of signal who can't use the press service if you see if there are
installed afterwards and this is a client-side implementation they choose to not support it once they
have checked it it's perfectly possible to use your unified push service afterwards and usually
most application gives an option to change your service if you want okay so if you want
you will be able to decide if you have other questions yes thank you all