Running an Android phone without Google’s proprietary Play Services - which drain your phone’s battery like mad - comes with the downside of not being able to receive push notifications. As I’m running CalyxOS with microG enabled basically all apps from Play Store (via Aurora Store) still will receive push notifications. However, if I have the choice I always opt for installing apps via F-Droid and those apps have all proprietary code removed and thus the dependency on Play Services.
This affects mainly messenger apps and they will then simply keep running in the background and poll the server from time to time. This comes with a little more battery drain. In my case for example I have SchildiChat installed which is a very nice Matrix client for my self hosted Matrix server. Like Element it kept a notification indicating it was waiting for new messages. However, SchildiChat is supporting UnifiedPush already (I think Element will also in the future).
So what is UnifiedPush? Briefly it’s an open source way of receiving push notifications. You can choose between different “distributors” (the application on your device listening for notifications) and “providers” (the server connected to the internet which will push the notification). This is where ntfy comes in. ntfy can be used for UnifiedPush but also - and I think this was the main purpose at first - to generate and receive custom notifications. You should definitely check out the website. The developer takes a lot of care in documenting, explaining and giving examples. He is also running a free instance of ntfy which you can use. Running your own instance is quite easy though and I’d recommend it, especially if you’d like to make use of your own custom topics. You can send notifications to those topics, however, anybody who is aware of the topic name can also subscribe to this topic. So make it very unique! When running your own instance you can restrict access.
I will not go into detail of the installation procedure as it’s documented in detail on the website here. You should also setup nginx as reverse proxy to handle SSL connections and also follow the hints about fail2ban and bad actors. You will find an example nginx configuration here as well. The ntfy service itself will be configured by
/etc/ntfy/server.yml and all options are explained pretty well. To restrict access you need to set “
auth-file” and “
auth-default-access”. If you installed ntfy by deb package you can simply use “
/var/lib/ntfy/user.db” for the former. The latter of course has to be set to “
deny-all”. Now you need to grant access at least to yourself. You can do that by (as root):
This will also grant admin privileges. Find the documentation about access control here.
There is also one important thing if you want to make use of UnifiedPush which I missed at first and it took quite a while until I figured out why UnifiedPush was not working. Found the solution here. To still enable UnifiedPush to write notifications you need to enable anonymous write access to topics starting with “up…“:
Now head over to your favorite app store and install ntfy. First thing you probably want to do is go to “Settings” and add your ntfy server as default and configure your user and password there as well. If you have SchildiChat installed it should automatically detect ntfy as push provider. You can verify by checking “Settings => Notifications => Notification Targets”. Enable “Force custom push gateway” and you should see something like this:
Since version 1.26 ntfy comes with a Matrix push gateway included.
Of course now I just exchanged the background service of SchildiChat with that of ntfy. However, if you have FediLab installed it will also use ntfy for pushing notifications. And they should come in with (almost) no delay.
The beauty of ntfy is that you can use it for your own custom notifications simply by using curl! Create a topic and let curl post notifications to this topic, i.e.:
This comes quite handy for letting you know for example if some scripts on your server failed (or were successful) or even if someone logged in via ssh. Find some fine examples here. That’s the fun part! :-)
There is an app for iOS as well, but I can’t tell from my own experience if there are any differences in terms of features or usage.