nucleus-ffm / foss_warn

An unofficial open source application to get emergency alerts from https://warnung.bund.de/meldungen.
GNU General Public License v3.0
97 stars 6 forks source link

Use Push notifications #27

Open davidak opened 2 years ago

davidak commented 2 years ago

As it can be critical that notifications are delivered instantly, Push notifications should be used when technically possible. (Android with Google Services or microG)

If not possible, tell the user that it takes up to 15 minutes to manually check and offer instructions to install microG (it is very hard, maybe not viable).

This might decide between live and death of a user or their family!

nucleus-ffm commented 2 years ago

It would be really cool to have that, but for any kind of push services (maybe with a websocket) I would need a webserver, but I don't have one. And even if I were to rent one, I'm not sure I'd have the time and skills to maintain the server all the time. Also, I had to think about how to finance the server.

davidak commented 2 years ago

I understand it's not easy. Maybe a solution can be found.

Maybe you can find contributors who love to maintain a server.

Would funding help? The project might have a good chance to get funding from Prototype Fund.

jugendhacker commented 2 years ago

Maybe unified push could be used so that it will still be compatible with F-Droid? Fluffychat does this for example.

budda85 commented 2 years ago

There is for example Ntfy . It is very easy to install. Fluffychat has automatic create an pushservice with ntfy.

jugendhacker commented 2 years ago

@budda85 yeah Fluffy just uses unified push, which Ntfy happens to be one provider for...

citizenserious commented 1 year ago

NextPush would be an option for me and maybe for others too. It is implemented in fedilab and Element as an example (:

bt90 commented 1 year ago

I'm not sure if an ntfy server alone would cut it. Aren't the UnifiedPush endpoints autogenerated? e.g. https://ntfy.sh/upMg6xDhy2UGUW

So we would need an additional service to handle registration and publishing for these endpoints.

Being able to register a UP receiver for a predefined server and topic would avoid that.

@binwiederhier is this possible?

bt90 commented 1 year ago

@binwiederhier (had a typo in your username)

karmanyaahm commented 1 year ago

Yes, just UnifiedPush alone won't do. Currently, the app talks to the government API every so often. But, for push, there would need to be a server that talks to that API, perhaps every 15 seconds, and then pushes to everyone registered on that server.

@vkrause is currently experimenting with a server like that for KDE, and since it sends data over UnifiedPush, it should work even for an Android app.

See: https://floss.social/@VolkerKrause/109477562343881737 And the server: https://invent.kde.org/vkrause/kpublicalerts/

ChaosNicro commented 1 year ago

I have seen people successfully parse server notifications to an https endpoint, tricking the server into sending to a UP distributor. But with no insight into NINAs communication protocol, that wont be viable.

nucleus-ffm commented 1 year ago

@ChaosNicro I am not sure I understood your post correctly. Can you give me an example of someone who has done this?

nucleus-ffm commented 1 year ago

Btw, here's a quick update on this topic.

We are currently experimenting with a push server written with NodeJS that uses unifiedPush to manage subscriptions and send push notifications. The server is of course also open source https://github.com/nucleus-ffm/foss_warn_server. At the moment it is still very simple and limited to the bare essentials - just for experimenting. The Flutter part is also in progress in the https://github.com/nucleus-ffm/foss_warn/tree/push-service branch. Since the whole server part is new to me, it would be great if someone would help me with it

However, there is a big problem at the moment. The Flutter connector https://github.com/UnifiedPush/flutter-connector is not compatible with the AlarmManager at the moment. When the AlarmManager is initialized, the callback functions of the Flutter connector for e.g. new Message are not called. I have already created an issue for this https://github.com/UnifiedPush/flutter-connector/issues/123 If someone here has an idea how to fix this, maybe they can help to solve the problem.

ChaosNicro commented 1 year ago

@ChaosNicro I am not sure I understood your post correctly. Can you give me an example of someone who has done this?

Sorry, I was drawing from https://github.com/Telegram-FOSS-Team/Telegram-FOSS/issues/577#issuecomment-1285792906 Like I said, probably not an option. The idea is to impersonate a (NINA)-Client and have the server send updates to a given UP-Server when registering the client. But that's not easy with proprietary apps. It's just odd that a public service like this doesn't just provide an open push-option, but just a polling-API.

p1gp1g commented 1 year ago

@nucleus-ffm I have tested with unifiedpush:^5.0.0 and it seems the issue is resolved. Could you try it ?

Edit: False alert :(

nucleus-ffm commented 1 year ago

@p1gp1g I tried it and as before, as soon as I initialise the AlarmManager, the callbacks stop working. I tried unifiedpush:^5.0.0 and android_alarm_manager_plus: ^2.1.4 with the UnifiedPush example app. @MatsG23 maybe you could try this too?

p1gp1g commented 1 year ago

I have probably been too fast with my tests with Foss_Warn. Sorry for the ping

MatsG23 commented 1 year ago

When I try running foss_warn_server, I get this error in the console:

SQLITE_CANTOPEN: unable to open database file

Must I create this file somehow or do you have to check it in to Git?

Can the dialog in the app saying that you would need to install a distributor ignored? Could you also give me some more instructions on using the server? I saw you created some python files, do I just have to run testRegistration.py after starting the NodeJS server?

nucleus-ffm commented 1 year ago

@MatsG23 Oh yes, sorry. I forgot to check if the db folder existed and if not, to create one. I have corrected this and pushed the changes. Also the FOSS Warn part is now updated. It should work now. You will need to install a distributor. I use ntfy

How to use the server:

The Python scripts are only for testing the server. They just send a dummy request to the server to check if it works as expected. If you want to test the server, just run the testRegistration.py file and you should get a "success" back.