android icon indicating copy to clipboard operation
android copied to clipboard

[Feature Request] UnifiedPush for push notifications

Open jacktheripper19 opened this issue 2 years ago • 14 comments

Is your feature request related to a problem? Please describe.

  • The NC app from the Play-store uses Google Firebase Cloud Messaging to deliver push notifications. As Nextcloud is used by many privacy aware users, this is not ideal.
  • The NC (and NC Talk) app from f-droid lack in push notifications completely.
  • Given that NC is mainly relying on FCM for push notifications, as A FOSS app, the majority of people using NextCloud are those who are running away from proprietary Cloud Services likes Google Drive,... and value their privacy so there is high chance that they don't use Google Services in their phones and not many of them are using Micro-G either.

Describe the solution you'd like

If every FOSS app that needs to push notifications implement their own push notification system, battery will drain faster because every app will have to check every x seconds, even if when optimizing the process. I propose that NC uses the UnifiedPush project https://unifiedpush.org/ which is being actively developed and is working properly. It also allows the use of FCM, so both worlds and there's a push provider for it (Gotify-UP) available at F-Droid .

The design flow would be something like:

  • The Google Play version will use FCM if it is available.
  • The F-Droid version will use UnifiedPush distributor (Gotify-UP, NoProvider2Push, ...) if it available.

Describe alternatives you've considered

Use Micro-G not sure if it supports FCM implementation but even that, metadata about notification are still sent via Google

Additional context

UnifiedPush currently supports the open source push provider Gotify-UP available on F-Droid and Google FCM. It's being used by IM apps like FluffyChat and others are working on it like Element.

jacktheripper19 avatar Jul 10 '21 10:07 jacktheripper19

Another option, not sure if it would be more or less work to implement (for both users and nextcloud developers) is to use a persistent notification. Apps like K-9 and Telegram FOSS use this approach. But definitely not providing notifications at all for the app distributed via f-droid is too disruptive, and probably the user should be notified when the app is first run (I recently moved to use the f-droid version and didn't notice after a few days that I lost all my notifications, I think for now I will sadly need to go back to Google Play).

llucax avatar Aug 02 '21 07:08 llucax

Another option, not sure if it would be more or less work to implement (for both users and nextcloud developers) is to use a persistent notification.

I assume by this you mean, use a persistent notification to remain running in the background and keep a connection open to the server? This is a bad idea IMO. It takes a lot of work and is very tricky to do this in a battery-efficient way. It also doesn't really scale to all apps on the device doing this. You really want a central push provider to keep a connection open because that minimizes how much you have to wake up the radio.

strugee avatar Aug 02 '21 17:08 strugee

A Nextcloud app called Push Notifier has quietly appeared for push notifications on Android. See discussion thread and project gitlab repo.

sunjam avatar Sep 03 '21 13:09 sunjam

A Nextcloud app called Push Notifier has quietly appeared for push notifications on Android. See discussion thread and project gitlab repo.

That's good idea. In principle. But it is not that good, as it sounds. Googles Push-Service helps to save energy. Only the Notification-push-Receiver has to be active on the phone, and not all the apps too. No wakeups and so on...

If every App brings it's own push-notification-receiver, i can run all apps instead too... So... unifiedpush is an approach, which is very senseful. Give me the possibility to run my own selfhosted notification-service-host, and have one notification-receiver on my smartphone instead of surveillance google-play-services...

So please integrate nextcloud notifications into unifiedpush.

xundeenergie avatar Oct 13 '21 05:10 xundeenergie

Should be a cascade:

Is FCM present? Use FCM. If not...
Is Unified Push present? Use UP. If not...
Use persistent notification.

OR

Just make it a user setting:

  • FCM
  • UP
  • persistent notification
  • no notifications

strider72 avatar Oct 26 '21 15:10 strider72

There is: https://github.com/UP-NextPush/ integrating UnifiedPush nicely into nextcloud. The login with SSO in the android app worked smoothly.

tacruc avatar Feb 20 '22 20:02 tacruc

Just out of curiosity, why hasn't there been a further push on this (no pun intended)? One of the main reasons many people move to Nextcloud is to get away from the cloud providers like Google... So it makes sense to completely de-google Nextcloud by implementing UnifiedPush. I almost feel that for the sake of privacy and those who are trying to have phones that are completely de-googled, this would be a huge plus. At this time, Nextcloud is literally the only reason I have to have MicroG installed on my android phone (have tried the notification service provided in f-droid, but it doesn't really allow for the same level of usefulness as normal notifications do).

bugbountyguy avatar Jul 26 '22 15:07 bugbountyguy

My understanding is nc offers their own unifiedpush server. See

https://apps.nextcloud.com/apps/uppush

On Tue, Jul 26, 2022, 8:57 AM bugbountyguy @.***> wrote:

Just out of curiosity, why hasn't there been a further push on this? One of the main reasons many people move to Nextcloud is to get away from the cloud providers like Google... So it makes sense to completely de-google Nextcloud by implementing UnifiedPush. I almost feel that for the sake of privacy and those who are trying to have phones that are completely de-googled, this would be a huge plus. At this time, Nextcloud is literally the only reason I have to have MicroG installed on my android phone (have tried the notification service provided in f-droid, but it doesn't really allow for the same level of usefulness as normal notifications do).

— Reply to this email directly, view it on GitHub https://github.com/nextcloud/android/issues/8684#issuecomment-1195667260, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANUKZSFDYEE7SY2LY4M2TTVWADEXANCNFSM5AED5YIQ . You are receiving this because you commented.Message ID: @.***>

sunjam avatar Jul 26 '22 16:07 sunjam

@sunjam ah, I think I misunderstood that that app required a different custom nextcloud installation that worked with that. I didn't realize it was an actual nextcloud app that can be integrated into the existing server. I'll check this out later and see if it works with the apps (In particular, NC Talk, News, and Deck) on my device. Thanks

bugbountyguy avatar Jul 26 '22 16:07 bugbountyguy

Just to share an update on this - doesn't look like UP-NextPush works with the nextcloud apps. Not sure if I just configured the phone app wrong or what (looked like it was simply just logging into it and that's it). It shows two dialogues - one that seems to show it's connected, but also one that says "disconnected". Server sees the phone as being connected, but yeah. Installed the f-droid version of NC Talk and such, and no notifications when testing it out, so had to go back to the google play versions.

Edit: Did a little more research on this. I think there are 2 things missing that I didn't realize:

  1. The Nextcloud server needs to be public/Internet facing (Mine's not)
  2. The app needs to be setup to work with UnifiedPush

So sounds like since I am not willing to make my NC server internet-facing, this isn't going to be an option for me even if the apps worked with UP? :thinking: Or is the real translation that "as long as your device has access to the NC server"? Because that's (obviously) true for me.

bugbountyguy avatar Jul 28 '22 19:07 bugbountyguy

I think you messed some things up ;)

The UnifiedPush Nextcloud App for the server is a user-choosen distributor. So if you install this app to your server and install their distributor app, you can use it to receive notifications for third-party apps which support UnifiedPush (like Element or SchildiChat). Hence it is a (drop-in) replacement for Gotify-UP. @bugbountyguy If you want to use your already running Nextcloud server as UnifiedPush provider, you can do that using this distributor. However, your Nextcloud must be reachable from the public internet, otherwise the application servers (Matrix server, …) cannot send you any notifications.

The Nextcloud Android app still needs to become a UnifiedPush supporting app so its notifications can be received using any UnifiedPush provider. That's why UnifiedPush is great, it lets use choose the server we want to trust to deliver our notifications.

See this chart for clarification (or read more on https://unifiedpush.org/):

Chart from UnifiedPush explaining Distributors

Chart from UnifiedPush explaining Distributors

Zocker1999NET avatar Aug 05 '22 08:08 Zocker1999NET

If an Android dev needs more inspiration on how to implement support for UnifiedPush, here is the PR which implemented it into Element. They use library which is a kind of drop-in replacement for Google's FCM library. The library will favor UnifiedPush if the user has installed it (it can be expected that a user which has a UnifiedPush provider installed might want to use it), but can fallback to using FCM directly.

However, the server may also needs an adaption as it needs to allow the Android app to submit any URL, which the server then should send its push notifications to.

Zocker1999NET avatar Aug 05 '22 08:08 Zocker1999NET

I also request unified push support. Running latest Android client on /e/OS gives a message box in the notifications screen saying that push is not working due to missing Google services (even though other apps work with MicroG implementation of FCM).

Having now Tusky and Synapse/Element supporting UnifiedPush, having this for Nextcloud would be highly appreciated. Running my own ntfy server. Works really well.

Setting the unified push server address would be best on a per user base, where the client retrieves a default from the Nextcloud server but the user can change it to another one. The Nextcloud server though needs to push messages based on the user's choice to the UnifiedPush server by the user. This way any user can choose its own unified push server and that's what is expected (having only one push connection per Android device). I believe, Element and Synapse have it implemented this way.

ne20002 avatar Sep 20 '22 06:09 ne20002

For clarification about UnifiedPush: UP requires the app server (here Nextcloud) to support "any" UP server and the server cannot propose a default server for UP. It's up to the user (by installing an UP distributor app) or the OS (by integrating it preinstalled, like Google does) to select & provide the required information about the "UP server" (if any is required, see here).

If an app wants to enable UP, following happens (assuming ntfy is used as the distributor):

  • Nextcloud Android checks locally if the user has installed ntfy (or any other UP app) with a defined broadcast
  • ntfy, in this case, returns "yes" and an https endpoint it generated (similar to the FCM token per app)
    • this endpoint probably contains an unique identifier & an auth token, but its embedded in a way so Nextcloud does not need to care about authentication
  • Nextcloud Android receives the endpoint and sends it to its Nextcloud server
    • a.k.a. "if you want to send me push notifications, send them to this endpoint"
  • Nextcloud server verifies that the given endpoint supports UP
  • for an upcoming push notification, the Nextcloud server does send its notification (or just the hint, that a new notification is there) to the given HTTP endpoint
    • Nextcloud server does not even need to know that it talks to a ntfy server, it only needs to send push notifications to the endpoint set by the user's app
    • It can send up to 4096 bytes of payload in its own format. The Nextcloud app will receive the same payload later.
  • the ntfy server forwards the payload in any given way (in case of ntfy: websocket or polling connection) to Nextcloud
  • the ntfy app receives the notification and sends it locally to the app via a defined broadcast

The best practice would then be that the UP endpoint is stored per client (not per user) as multiple clients can (and most probably will) use different endpoints (maybe even different services). Like stated above, the endpoint address may be handled like the FCM token. And that the user cannot configure the UP endpoint via the UI but will be generated by the UP distributor app (ntfy) and set by the Nextcloud app in the background.

Zocker1999NET avatar Sep 20 '22 22:09 Zocker1999NET

+1 for unified push support for nextcloud client apps

crashbandicode avatar Jul 03 '23 11:07 crashbandicode

Hey @crashbandicode! Please don't add +1 comments, as they don't contribute anything to the discussion and just generate more email for the maintainers (and those who are subscribed to this issue) to go through. Instead, you can support issues by using GitHub's reactions feature (smiley icon at the top-right of each comment). Alternately, if this feature is important to you, you could contribute a patch yourself.

strugee avatar Jul 03 '23 15:07 strugee