nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.16k stars 1.75k forks source link

UnifiedPush for push notifications #8684

Open jacktheripper19 opened 3 years ago

jacktheripper19 commented 3 years ago

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

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:

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.

llucax commented 3 years ago

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).

strugee commented 3 years ago

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.

sunjam commented 3 years ago

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

xundeenergie commented 2 years ago

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.

strider72 commented 2 years ago

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:

tacruc commented 2 years ago

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

bugbountyguy commented 2 years ago

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).

sunjam commented 2 years ago

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: @.***>

bugbountyguy commented 2 years ago

@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 commented 2 years ago

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.

Zocker1999NET commented 2 years ago

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](https://unifiedpush.org/img/animation.svg)
Zocker1999NET commented 2 years ago

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.

ne20002 commented 1 year ago

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.

Zocker1999NET commented 1 year ago

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):

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.

crashbandicode commented 1 year ago

+1 for unified push support for nextcloud client apps

strugee commented 1 year ago

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.

gavine99 commented 1 week ago

I have submitted some pull requests that don't change architecture to achieve nextcloud notifications to be sent via the 3rd party unified push app. see;

https://github.com/nextcloud/server/pull/47763 and https://github.com/nextcloud/notifications/pull/2027

... also a pull request for the 3rd party unified push app that can be applied after the pull requests above are applied; https://codeberg.org/NextPush/uppush/pulls/17

i have also submitted pr's for the generic (f-droid) android nextcloud client and talk apps to use the nextcloud server changes and these changes to create an end-to-end solution for unified push notifications and talk; nextcloud mobile client app: https://github.com/nextcloud/android/pull/13516 nextcloud mobile talk app: https://github.com/nextcloud/talk-android/pull/4146