How to setup push notification with Synapse and Element (or Element X) Android

Context

With the Arrival of Element X the new version of element for Android, users will need to have push notification configured correctly. For user which use Element X from Google play most of time it will work by default by using the google service for this. But for degooglised Android phone the question is generally be more complex. It’s why I wrote this tutorial to explain the context of this and the different possibility to setup a correct notification system.

Notification provider

There are several notification provider that we can use on Android. On this tutorial we will focus on ntfy which is one of the provider. This require to have the ntfy application installed on your phone and also a ntfy server. You can use the official ntfy server or self host the ntfy Yunohost application. Self hosting ntfy is the most complex setup and I’ll focus on this option.

Setup

Synapse configuration

You will need to configure synapse to allow to send request locally to ntfy. For this you can do it from the config panel in: “Advanced Settings” > “Security”. And then enable the parameter: “Allow synapse to send request to localhost”.

Ntfy setup

Firstly you will need to install the ntfy application if it’s not already done.

Then you will need to create an account for each users. You can do this by this command:

sudo -u ntfy /var/www/ntfy/ntfy.sh user add <username>

Then you will need to configure the Android app to use your ntfy server and use the user that you created previously. You can do this from the ntfy app settings in the “General” section.

You will also need to create a dedicated subject into your Android app for the Element notifications. For this the most simple solution would be to launch notification diagnosis into Element X settings. It will create a new notification subject if it’s not already created. You can do this from Element X, in the settings in > Notifications > troubleshooting notifications > run the tests.

After that you should have a last one topic into ntfy (in the Android app). For each topic linked to your self hosted server you will need to configure the rights with theses 2 commands:

# Allow the user to read/write notification
sudo -u ntfy /var/www/ntfy/ntfy.sh access <user> <topic> rw
# Allow everybody to write (needed by synapse to push notifications
sudo -u ntfy /var/www/ntfy/ntfy.sh access everyone <topic> write

# Optional, check all rights
sudo -u ntfy /var/www/ntfy/ntfy.sh access

After that you can run again the test notification from element X and everything should work.

Side note

It could happen that some others app add some new additional topic later. It was by example the case on my side with Tusky. In this case you might have some notification issue because ntfy will have some issue with the new registered topic which has not the right configured. In this case you will just need to configure for the new topic the right as described above. Just keep in mind that this could happen.

Side not for /e/ OS users

By default /e/ OS already integrate the ntfy application so you won’t need to install any additional apps. But the apps is hidden so it need some trick to configure it.

Firstly you will need to enable UnifiedPush (if not already done). For this, open the system settings > System > UnifiedPush. And then enable the button “Enable the distributor”.

At some point you will also need to open the ntfy app. Currently there are no way to open this directly from the UI so there are 2 solution that I found for this.

Use the activity manager application to create a new button

The most recommended solution would be to install the activity manager application. With this application you can create any new shortcut to open a lot of activity. With this application you can find the ntfy application (foundation.e.ntfy) and create a new shortcut to open the main activity from the main screen.

Open with ADB

An other solution would be to use ADB as described into this blog post. So just you just need to run this:

adb shell am start -n foundation.e.ntfy/io.heckel.ntfy.ui.MainActivity

And this will open the ntfy app provided by /e/ OS

6 Likes

Thanks a lot for this tutorial.
I have switched to a degoogled rom about a year ago. I installed FluffyChat, Element X, Schildichat and may be another app to choose from them. I settled with FluffyChat. I’ve also installed ntfy android app using the default server.
It worked fine a couple of months till I had to install fb messenger because at work and in our university all of the colleagues and collaborators use it, intensively :roll_eyes:. It’s like FluffyChat can’t run background.
New messages count gets updated only after opening the app.

thanks for the /e/os tips

Thank you for this tutorial. Are there any security issues using the ntfy default server? Also can I use nfty for other apps like e.g Molly.IM or others?

Just adding some notes:
If your ntfy user is also the admin of the ntfy service there is no need to give rw rights to topics.

I had notification issues with some rooms, which were muted, and couldn’t unmute them from element x/schildichat next. Doing a little research I found out that push rules in synapse are set at server level, so if you mute or unmute a room it will be on every client used to access it.
For some reasons element x can’t revert the push rule if it has been set from element desktop (and I guess from element v1).
Aftet unmuting the rooms from my desktop client the setting propagated also to my element x client

Well, it depends what you mean by security issues. If you mean about the data privacy, yes it could. At last the notification is send to the default ntfy server.

Yes, you can. On my side I saw that tusky also use the push notification.

1 Like

Thks.