Firefly-Social / Firefly

An android Mastodon client
Mozilla Public License 2.0
38 stars 1 forks source link

Push notifications #43

Open devotaaabel opened 6 months ago

devotaaabel commented 6 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.