Firefly-Social / Firefly

An android Mastodon client
Mozilla Public License 2.0
54 stars 2 forks source link

Push notifications #43

Open devotaaabel opened 9 months ago

devotaaabel commented 9 months ago

Android notifications are typically done using Firebase Cloud Messaging (FCM). FCM is a proprietary system, and the android sdk is closed source, so I would like to avoid using it. Enter Unified Push. Unified Push does not require play services, but it does require the user to have a distributor app installed on their device. Many fediverse apps use Unified Push.

We can use an Embedded FCM Distributor library to enable Unified Push, but also fall back to FCM for users who do not have a distributor but do have play services. However, this would require us to setup a rewrite proxy server to translate the WebPush API to FCM (I think that's what it does?). So I would prefer to just not use FCM at all.

I think ideally, we would want to use UP and connect to the user's distributor app. But if they don't have a distributor app, we could fallback to an embedded distributor that uses a service like ntfy.sh. However, I'm not aware of any embedded distributor libraries, aside from the FCM ones. We need to find out of there are any embedded distributor libraries that we can setup to point to any UP server we want. If not, maybe we make one ourselves?

In order to fetch notifications after we receive a push, we will need to use the markers api to fetch the last seen notifications, then the notifications api to get the notifications since that marker.

Upon creating an android notification, we need to update the marker using the markers api. We also need to update the marker when the user views the notifications tab.

JohnOberhauser commented 1 month ago

blocked by this https://github.com/mastodon/mastodon/issues/26078 Unless I set up a personal ntfy server, but I'm lazy

playforvoices1 commented 1 month ago

blocked by this mastodon/mastodon#26078 Unless I set up a personal ntfy server, but I'm lazy

I use the Moshidon client with build in ntfy support. But I'm not sure how it works inside the app.

JohnOberhauser commented 1 month ago

@playforvoices1 Can I ask what mastodon server you use? Also, what unified push server do you use? ntfy.sh?

I use ntfy.sh and I have accounts at fosstodon.org, mastodon.social, and mozilla.social.

There is either

  1. An issue with all three of those servers
  2. An issue with mastodon in general
  3. Or an issue with ntfy.sh

I'm unable to test my implementation because I can't get mastodon to send me a push. I tried moshidon, and enabled unified push in the settings, and I'm not getting notifications with that either. Can you confirm that you have unified push enabled in moshidon (settings -> notifications -> unified push)? And can you confirm that you receive push notifications in moshidon?

playforvoices1 commented 1 month ago

I can confirm that I use Moshidon with unified push enabled. I use the kanoa.de mastodon server. The admin there also use the ntfy.sh app for receiving notifications.

If you need my setup, please let me know.