krille-chan / fluffychat

The cutest instant messenger in the [matrix]
https://fluffychat.im/
GNU Affero General Public License v3.0
1.23k stars 222 forks source link

Notifications doesn't work properly on Android with UnifiedPush #544

Open parrazam opened 1 year ago

parrazam commented 1 year ago

Bug Description

I have 2 accounts registered in FluffyChat, one using the default server matrix.org and another one using a custom server. I'm using Ntfy as notification server.

When I add both accounts in the app, the first one register the device in the Ntfy server. However, the second one doesn't. So I can receive notifications for the first account but not for the second one.

Steps to Reproduce

  1. Log in in the app with an account.
  2. Check that the notification device is registered under Settings -> Notifications -> Devices
  3. Log in with another account from a different server.
  4. Go to Settings -> Notifications -> Devices and no one device was registered.
  5. Send a message to the first account. It will be notified.
  6. Send a message to the second account. It won't be notified :(

Expected Behavior

Each account should register in the unifiedpush server, in order to manage notifications independently.

App Version

1.13.0

Additional Platform Information

Device: OnePlus 8T, OS: Android 13

Additional Context

No response

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 120 days with no activity.

marcan commented 11 months ago

This is stilll broken.

Doomsdayrs commented 10 months ago

Just found this out as I was starting to use FluffyChat for my multiple accounts

cassandracomar commented 10 months ago

I tested this by enabling and disabling notifications for each account. each time I do so for one account, I can receive notifications for that account (DMs only -- notifications for group chats never work) but not the other.

TimSchimansky commented 9 months ago

Yes this is also happening with the google play version, which I installed in the hope to fix this, but I only get DM-notifications for the first account. (Both are custom servers)

squatica commented 6 months ago

If you are really desperate, here is how to register a pusher manually by directly calling the matrix API:

First you will need you access token and the url of the matrix api.

Api url is easy, take the domain part of your account name (such as "matrix.org") and look at https://matrix.org/.well-known/matrix/client - if they show m.homeserver -> base_url then that is the API url, if not, then the domain part of your account name is the API url. Matrix.org has api at https://matrix-client.matrix.org. Do this for both of your accounts and let's call them MATRIX_HOST_1 and MATRIX_HOST_2.

To get the access tokens, you can either steal them from a web client by inspecting the Authorization headers (any access token of the particular user account should work). I don't know how to get it from Fluffychat, but we could just do a new login on command line:

(Be extra careful with that access token, and that curl command containing your password. If you don't know how to avoid leaking them, or accidentally storing them in some cache or history, don't proceed.)

curl -XPOST -H "Content-Type: application/json" \
  -d '{"type":"m.login.password","identifier":{"type":"m.id.user","user":"YourUsernameHere"},"password":"YourPasswordHere"}' \
  "${MATRIX_HOST_1}/_matrix/client/v3/login"

Get both access tokens, let's call them ACCESS_TOKEN_1 and ACCESS_TOKEN_2.

Get the pusher settings from the first account (the one where push notifications work):

curl -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${ACCESS_TOKEN_1}" \
  "${MATRIX_HOST_1}/_matrix/client/v3/pushers"

From the response take only the object inside pushers:[...] and add this part: "append":true - this can be done with jq:

curl ..../pushers | jq -rc '.pushers[0]+{append:true}'

Now send the resulting json object to the second account's api, to set the pusher:

curl -XPOST -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${ACCESS_TOKEN_2}" \
  --data '{"app_display_name":"..."... ,"append":true}' \
  "${MATRIX_HOST_2}/_matrix/client/v3/pushers/set"

This will effectively clone the exact same UnifiedPush settings from your first account. Now fluffy should be getting the notifications, however it's not 100% ideal, seems like fluffy will show the username of the first account, but at least the notification is there and clicking it opens the correct room in correct account.

Of course this is super hacky solution, so only do this if you are willing to solve whatever breaks. So far it seems to have worked for me, YMMV.

gusarg81 commented 6 months ago

Yes this is also happening with the google play version, which I installed in the hope to fix this, but I only get DM-notifications for the first account. (Both are custom servers)

Hi, I second this. I've reinstalled using Google Play (because was not working with Ntfy) and still notifications does not work.

I have 2 accounts. Boths with self hosted servers. With Element Notifications does work.

Yarrax commented 1 month ago

It's still actual bug. Android 14, Fluffy 1.22.0 I receive push from first account and dont receive form second account.

gusarg81 commented 1 month ago

It's still actual bug. Android 14, Fluffy 1.22.0 I receive push from first account and dont receive form second account.

Yes, the same is happening to me too currently.

baltevl commented 3 weeks ago

I have written pr #1443 to fix this. Any feedback and/or testing is welcome :)