Fixed! Android Proton mail notifications without play services

Notifications for Proton mail. No google play services needed

I should specify…. This does NOT fix the Proton Mail app itself. This post let’s you run Proton Bridge on your android device which then allows you to use a 3rd party email client, which then has working notifications.

This is a post for people who want Proton Bridge running on their android device and for people who want notifications without having google play services installed (GRAPHENEOS for example).

It uses about 1% of battery for me from a full charge.

This setup only takes about 2 minutes or so to do, nice and easy.

It installs the bridge and sets a script to automatically start the bridge when your device boots.


IMPORTANT

You can remove Termux from your recent apps list and the bridge stays running… BUT, see the below note…

If you force close Termux or it crashes, your email client will not know and won’t give any errors. If you try to send an email, you’ll get an error notification from your email client… If this happens, run the following command to restart the bridge…

proton-bridge --cli

The only solution that I know of for if these 2 events occur is to have an automated task to check and restart the service if the bridge stops……. More info at the bottom of the post


===============================

  • Install Termux and Termux:Boot
  • Give them unrestricted battery usage
  • Give Termux network usage
  • Open Termux:Boot once, then close it (this initialises the app)

TERMUX COMMANDS…

  • pkg install pass proton-bridge -y
  • proton-bridge --cli
  • login
  • info (IMAP/SMTP info for your email client)

This session will have the bridge permanently running, so you need to start a 2nd Termux session for the rest of the commands…

  • cd ~/.termux
  • mkdir boot
  • cd boot
  • pkg install vim -y
  • vi proton.bridge
  • i

Paste these 3 lines…

  • !/data/data/com.termux/files/usr/bin/sh
  • termux-wake-lock
  • proton-bridge --cli

Press the escape button

  • :wq (on the keyboard, type ‘:wq’)

===============================


I’ve been playing around with Macrodroid too…

Because I’m very particular, I’m trying to make a macro using the Termux:Tasker app which is a plugin for Macrodroid/Tasker.

I want to make an automated task so if the bridge ever shuts down, the macro runs to restart it.

By using this automated task as well as Termux:Boot, you are guaranteed to have the bridge start itself and run under all circumstances (booting your phone, Termux crash, force stopping Termux etc)

This achieves the goal of having Proton Mail notifications on any 3rd party email client at all times… The way Proton Mail app itself functions when play services is installed

==================================

Open Termux

COMMANDS

  • mkdir ~/.termux/workdir
  • mkdir ~/.termux/tasker
  • cp ~/.termux/boot/proton.bridge ~/.termux/tasker/

In Macrodroid or Tasker, create a macro/task using the Termux:Tasker plugin

In the config…

Executable: proton.bridge

Working directory path:

  • /data/data/com.termux/files/home/.termux/workdir

Uncheck “execute in a terminal session”

Save the config

=================================

I haven’t worked out a trigger for the macro/task yet to detect when the bridge shuts down, so for now, I have the macro/task set to run at an interval of every 5 minutes…

It sounds extreme but if you run the command (proton-bridge --cli) and the bridge is already running, it simply fails and tells you so…

So running this every 5 minutes doesn’t use internet and takes about 3ms (exaggeration), it basically won’t use any battery

2 Likes

I haven’t used this app, however I think it should be easy to get it running such that when it crashes, it restarts. It won’t solve the problem if Termux crashes but if proton-bridge crashes within the Termux session.

I’m assuming that proton-bridge hangs in the terminal, as in it doesn’t execute the next line in the script but just sits there. If that is the case, you want to something like the following in your ~/termux/boot/proton.bridge

#!/data/data/com.termux/files/usr/bin/bash

termux-wake-lock

while true ; do

proton-bridge --cli

done

It should be that easy. It just makes an infinate loop so that when it exits it goes back up and restarts. If it’s restarting too quickly, putting a delay after it will help

while true ; do

proton-bridge --cli

sleep 3

done

You can also try out starting proton-bridge like this in your script. I’ve seen people in discussion forums use this on older builds of android use it like the following, saying the android system was killing off whatever they were trying to run persistently in Termux, though I don’t have experience with it, I assume it would just kill Termux and not the process within it.

nohup proton-bridge --cli

If that all works out, then you might want to put the loop in it’s own script then call it from termux boot backgrounded and diswoned from the boot script that calls it. Make a file like this:

vi /data/data/com.termux/files/usr/bin/proton-bridge-script

Put your loop in it

#!/data/data/com.termux/files/usr/bin/bash

while true ; do

proton-bridge --cli

done

make it executable

chmod +x /data/data/com.termux/files/usr/bin/proton-bridge-script

Then call it from the boot script like this:

#!/data/data/com.termux/files/usr/bin/bash

termux-wake-lock

nohup proton-bridge-script & disown

This way you will get your wakelock, then the script will be called in the background as it’s own process, and your boot script will exit. The notification will say Wakelock held and 0 processes, most likely, but it will still be running as long as the wakelock is there, which frees you up to open another Termux terminal without extra hassle.

Notice in the last one I changed the shell from sh to bash in the first line. If you keep it how it was then don’t use the disown, just put it like this

nohup proton-bridge-script &

but I think bash should work fine. I’m using it in my termux boot.

Also I fixed the beginning of that line as well, it needed a # added.

It went from this

!/data/data/com.termux/files/usr/bin/sh

to this

#!/data/data/com.termux/files/usr/bin/bash

Ahhh, I see where you’re going with it…..

That’s actually a great idea and it would eliminate people having to install/use Macrodroid/Tasker.

I’m going to have a coffee, then I’m going to write a single script, just one, that will create all the necessary folders and scripts needed to run the bridge on boot AND check that it’s running every 5 minutes.

So for less technologically inclined people/ease of access to this idea, I’m hoping to have a single script called “Install.ProtonBridge” that you can open with Termux without the user needing to write a single line into the console….. Basically as easy as opening your camera app….one click

I’ll be back later haha

If you have any other ideas, let me know and I’ll integrate it…… should I allow the user to select how frequently that the bridge is checked when running the install script? Or leave it at 5 minutes? Cheers

I don’t know. I wish I could offer suggestions but I haven’t used proton bridge and I don’t know how to query what’s running in Termux from outside of it either. I think you must have a good grasp on that part and optimizing it for functionality and convenience with respect to battery savings is what you’re looking at when it comes to how often to check.

I imagine that you could also install termux-api from within Termux and from f-droid or obtanium then attempt to do a notification within it it the even that proton-bridge fails repetitivly in the loop, but I honestly don’t have any insight about looking from outside of it in another app.

Installing termux-api adds attack surface and is a downside of trying add logic to the script then call the app, internally…

So, I’ve only JUST finished this…. I’ve been working on it since my last reply :skull::skull::skull:

I made a totally foolproof script that installs, updates and is used to access Proton Bridge…. It’s literally an all-in-one script.
It’s also completely able to be audited, it’s basically a text file haha.

It makes full utilisation of the official Proton Bridge.

Have a look at the code if you’re curious and let me know your thoughts…

Install Termux and Termux:Boot from Fdroid or GitHub, then just tap on the script in your downloads folder.

Select the option to open with Termux if prompted, then select the ‘open directory’ option. This saves the script to the download folder within Termux. Termux will also open automatically.

Run the command ‘bash Proton.Bridge’ and follow the instructions

Proton.Bridge is recommended for most, if not all people.

Proton.Bridge.Basic is simply to show the executed code without all the extra “fluff” and comments.

This script does so much yet as you can see in the basic version, the entirety of the code fits on one phone screen.

Proton.Bridge.txt (4.7 KB)

Proton.Bridge.Basic.txt (1.0 KB)

The original file is called ‘proton.bridge’ but it had to be ‘.txt’ to be allowed to upload it. Just delete the ‘.txt’ before opening it with Termux

1 Like

Great work! Just a simple question: What advantages does your script have in comparison to installing something like YouHaveMail?

MUST READ

My apologies… I still had an old line of code that was preventing the boot file from starting on device boot.

I’ve now fixed it and updated the script file in my previous post… if you’ve already downloaded and run the script, just download and run the new one from the same message

Great work! Proton-Bridge on Android is something they should have offered anyway, also for those users who simply prefer to use another email client.

The caveat is that Proton-Bridge is “paywalled” and won’t work on a free account.

Thank you DailyChems :slight_smile:

I originally tried ‘You have mail’…. But it made me cringe to think that I was putting in my login details to an app that isn’t official. I have my banking, crypto, passwords etc all linked with access from my email.

I’m sure that the developer has good intentions but I don’t like the fact the an app that I don’t know, with code that I won’t understand, will collect and store my email login details.

But, it did give me the idea to try the bridge… it’s the official Proton Bridge from Proton, with all the E2EE and security that comes with it….

If you get a chance to look at my script, it’s very clear, short and easy-ish to see what’s happening. And when used, you don’t give the script your login details, you use them to login to the official Proton Bridge… regarding ‘You Have Mail’, I’m giving the app my login details, not Proton :skull::skull::skull:

Regime6045

Exactly!!! Signal, Tuta and others function without play services… what in the actual @#$! Proton???

It should all just work, as expected and as it should. Yeah that does suck for free accounts :broken_heart:

1 Like

It would be outstanding if someone could turn my script into a proper app, with a proper button and text box focussed interface like we should have from Proton :pinched_fingers::pinched_fingers::pinched_fingers:

I have a new plan…

I’ve setup some extra stuff like a side-by-side code comparison and a README document.

This is a link to a shared folder on my personal drive…

I decided to do this in case I add more info or upgrades or anything… it’s all in one place

I put a lot of effort into the README so let me know your thoughts haha…. Is it clear enough?

I’ve made an update for it

I’ve simplified everything, cut the code down about 30% and released version info.

I plan to release a copy of the script that has plain English descriptions (pseudo code) instead of code, so people can get a better understanding of what its doing :slight_smile:

I’m also looking into some form of super basic app that you can just install, run and update like a normal app….. Essentially what a genuine Proton Bridge android app should be.

And I also wanted to let people know…. The language that this script is written in is universal across android so I’d be extremely confused if this doesn’t run perfectly

1 Like

Perhaps upload it to Github or Gitlab so that people can help out with code contributions if it becomes popular

I would but I have no idea how to setup an account with contributors and this, that and the other :skull:

I’m perfectly happy for anyone to steal it and carry on the work haha. I just made it for myself originally but thought I’d share it because I know that a LOT of people need/want it :ok_hand:

As long as anyone that decides to take it, improve it and evolve it uses it for good and not evil :joy:

You just make an account on Github and upload your code. Then the rest of the documentation in a readme (markdown format). Add an open source license so others can fork it. That’s it, easier to find for random people than a link to Protondrive.

1 Like

Closing my proton account… here are the files

Make sure to remove the “.txt" from ProtonBridge.txt before running in termux

READ-ME.pdf (49.4 KB)

ProtonBridge.txt (2.7 KB)

READ-ME.docx (29.1 KB)

2 Likes