Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push notifications don't work #68

Closed
Antitoxic0 opened this issue Sep 19, 2023 · 18 comments
Closed

Push notifications don't work #68

Antitoxic0 opened this issue Sep 19, 2023 · 18 comments

Comments

@Antitoxic0
Copy link

I don't know if it's the right place to report my issue, cause probably it depends on my phone.

I can't get push notifications neither with NTFY (Tusky or Fedilab work correctly on my phone), nor without it.
I tried to switch ntfy servers and disable battery optimization without any success. I'm using a Samsung s8 with E os

@nikclayton
Copy link
Contributor

Thanks for the report. This was an ongoing issue with Tusky for some users (and not others).

Medium term I plan to add support for Google's notification system (if the app is downloaded from the Play store), which will hopefully resolve these issues. I also want to show the notification fetching mechanism on the about screen (#36) which might help troubleshooting.

In the meantime, some things to check (I know you've already mentioned some of these, I want to be able to point other people at this issue as well so they have some things to try).

Confirm you haven't disabled Pachli notifications

Open "Account preferences > Notifications". This should take you to the Android (not Pachli) notification settings for Pachli.

The relevant switches should be set to the on position.

If any of them show text like "About 1 notification per day" or similar that's a good sign -- it means that Pachli is sending notifications, even if your device is not displaying them to you.

Other apps checking notifications?

If you have other apps checking notifications, do they update the notifications marker with the newest notification they have seen? I know Tusky does, I'm not sure about Fedilab.

If so, this is one explanation -- to avoid creating duplicate notifications if you have multiple apps installed Pachli won't create Android notifications below that marker.

Suppose you have 10 Mastodon notifications, so the marker is "10". Two more notifications come in, the marker is now "12".

Then Tusky checks notifications first, shows two, and sets the marker to 12.

Pachli checks notifications some time later, sees that the marker is 12 and there are no newer notifications, so it won't create duplicate notifications.

In this context "other apps" includes the Mastodon web app. So if you have that open in a browser tab somewhere it might be periodically checking for notifications and resetting the marker before Pachli sees the notification.

If using ntfy...

Is app.pachli in the ntfy subscribed topics?

Open the ntfy app, and review the list of subscribed topics. You should see entries labelled "app.pachli (UnifiedPush)".

If you don't, Pachli hasn't registered correctly with ntfy for some reason, and is using pull notifications, where it will check every ~ 15 minutes for new notifications.

Is ntfy excluded from battery optimisation?

If you do see one or more entries in ntfy for app.pachli, check that ntfy is excluded from battery optimisation. Follow the instructions below to open ntfy "App info", and make sure the battery usage setting is "Unrestricted".

If not using ntfy...

If ntfy is not installed Pachli will check every ~ 15 minutes for new notifications. For this to work reliably battery optimisation for Pachli must be disabled on the device.

How you do this is probably different from device to device. On my Pixel 4a I

  • Long press the Pachli icon
  • Tap the i-in-a-circle in the menu that pops up
  • This opens an Android "App info" screen for Pachli
  • There's an "App battery usage" menu item on that screen, tap that
  • Set it to "Unrestricted".

I appreciate it's not much comfort if it's not working for you, but I just did that on my Pixel 4a, with ntfy installed, and it shows that Pachli battery life is "optimised", but I still get timely notifications.

@RobinChapman
Copy link

RobinChapman commented Sep 19, 2023

Hi Nik, thanks for the link to the issue #68 after my initial inquiry via Mastodon this afternoon.

Firstly I am running an Samsung with Android 10 - i don't know if you need that, but i have included it anyway.

First I did have Megalodon installed but i had stopped the apps notifications and then force stopped the app.
The only difference that this made was that I got no notifications at all from Mastodon.
So I uninstalled Megalodon - and still nothing from the Pachli app.

Next, I checked Settings > App notifications > Pachli

All Notifications were marked as being in the ON position,
However scrolling down through the list in section marked other, i noticed that 'Background Activity' was marked as off.
I changed this setting to ON and still received NO notifications form the app.

I checked back in on App Notifications, and many of the items for selection have further sub menus - 'Background activity' was one that does.
Accessing this menu settings > Notifcations > Pachli > Background Activity
You are then given the options of
Alert
Silent
Show as Pop-up
sound Vibrate App Icon Badges
Lock Screen
Ignore Do not disturb

Alert was already checked, but Show as pop-up was OFF > I set this in the ON position. then came back out, rebooted the phone and there are still no notifications coming to the phone
-- However when I open the Pachli App I now get a long box tht appears at the top of the screen once, that states "Fetching Notifications" but then it doesn't tell me in the app whether I have any or not - unless I go into the notifications menu option.

I am not using ntfy - However I have gone through the 'use details' for the Pachli app and disabled battery optimisation - fingers crossed.

-- Ok, this seems to have made a difference, I still don't get a notification that stays on the screen, but i get an audible notification that tells me that an app on my phone has received a notification, (as I set pachli with a different audible tone to my messaging apps I know that it was the app that was notifying me - However, there was no notification on the home screen, in the notifications bar at the top of the screen, and no notification within the app to show that something had been received and was waiting.

I hope this helps - I thought i was pretty good at getting stubborn apps working on android, but even this has me stumped.
Thanks for your help all the same - I hope the information above is useful. :-)

@Antitoxic0
Copy link
Author

Thank you for your tips. I'm keeping on trying without any success. I also removed any other Mastodon app could interfere with the notifications but nothing seems to work. In my case the phone doesn't detect any notifications in Android settings for Pachli.

@nikclayton
Copy link
Contributor

You don't see something like this (except with your account listed, not @[email protected])?

@Antitoxic0
Copy link
Author

(I'm sorry if my english isn't clear but i'm not expert in this type of things) Yes! But, as you mentioned before ("If any of them show text like "About 1 notification per day" or similar that's a good sign -- it means that Pachli is sending notifications, even if your device is not displaying them to you."), my phone doesn't show anything at all.
Other apps, although fail to show push notifications sometimes, they still report them in android setting notifications. Pachli instead doesn't report anything.

@fourlastor
Copy link

fourlastor commented Oct 1, 2023

I'm having the same issue (not using ntfy, Pixel 3a, Android 12).

If I had to guess, I'd say the main suspect is the way notifications are scheduled. I often had issues with periodic work requests and the workaround that seemed to improve things a bit was to replace them with one time work requests that reschedule themselves in the future when they finish.

You could do that by having a chain of work where the last worker just reschedules the whole chain (with a delay), and making sure the chain itself is unique and uses the KEEP flag.

I'd do a PR myself but the license doesn't allow me, I'm happy to test dev builds on branches though :)

@Antitoxic0
Copy link
Author

Any news on this issue? I'm still not receiving push notifications, could it be due to E.os on my samsung?

@rluetzner
Copy link

I'm having the same issue with ntfy on a Realme 7 device.
I've already played around a bunch with the notification settings, but so far haven't been able to get it to work.
However, I also enabled notifications for when I'm sending a post. These work!!! 🤯
Not sure if that info helps, but to me it seems like some notifications, specifically the generic ones and not related to an account, work perfectly fine. Another possibility of course is that in these cases my device was turned on and the app was in the foreground anyway.
I know next to nothing about Kotlin or Android development, but maybe this observation helps somehow.

@nikclayton
Copy link
Contributor

Thanks for the extra info folks, I appreciate this is frustrating if you encounter it.

It's frustrating to debug too, because I can't reproduce notification problems on my physical devices or in emulators, with and without ntfy.

I'm going to make some changes that surface additional information about the notification mechanism Pachli is using, how frequently it is checking for notifications, and what the results of those checks are to make this easier to track down. That should give more useful data about what's going on.

@nikclayton
Copy link
Contributor

FYI: those changes I mentioned will be in the next release of Pachli Current.

https://mastodon.social/@pachli/111909302213877669

When that's done I'll be asking people to report back here with the results so we can fix this once and for all.

@nikclayton
Copy link
Contributor

@Antitoxic0 @fourlastor @rluetzner @RobinChapman The latest version of Pachli Current (this will be included in the next Pachli release as well) has a new "Notifications" tab on the "About" screen.

Go there and you'll see many details about how Pachli has determined how to get notifications, and logs. You can also download the report and attach it to a bug report.

https://pachli.app/pachli/2024/02/17/debugging-notifications.html has many more details about how to interpret the results and save the information. Please can you review that and try the steps that are suggested there. If none of those fix the issue for you please use the "Download" feature to download a report and attach it to this bug so I can investigate further.

In the course of putting that together I discovered what seem to be a number of misfeatures in the original Tusky notifications code that I hope to fix, but getting those reports will help me determine the areas to focus on first.

If you're not already using Pachli Current you can get it from https://pachli.app/download/#pachli-current.

@SteveDinn
Copy link

I figure this is a better place to discuss what you mentioned in tuskyapp/Tusky#3935

I notice the little pop-up that says Pachli-Current is re-registering with UP-FCM every once in a while when I start up the app. I haven't particularly noticed that Pachli delivers notifications any later than any other Mastodon client app.

@Antitoxic0
Copy link
Author

Antitoxic0 commented Feb 20, 2024

@Antitoxic0 @fourlastor @rluetzner @RobinChapman The latest version of Pachli Current (this will be included in the next Pachli release as well) has a new "Notifications" tab on the "About" screen.

Go there and you'll see many details about how Pachli has determined how to get notifications, and logs. You can also download the report and attach it to a bug report.

https://pachli.app/pachli/2024/02/17/debugging-notifications.html has many more details about how to interpret the results and save the information. Please can you review that and try the steps that are suggested there. If none of those fix the issue for you please use the "Download" feature to download a report and attach it to this bug so I can investigate further.

In the course of putting that together I discovered what seem to be a number of misfeatures in the original Tusky notifications code that I hope to fix, but getting those reports will help me determine the areas to focus on first.

If you're not already using Pachli Current you can get it from https://pachli.app/download/#pachli-current.

With Pachli Current, I'm receveing push notification, just like that! Without any problem (I use ntfy). Instead with Pachli stable, 2.2.0, none; but i understand this version doesn't get the fixes still. Do you need my report anyway?

EDIT post Pachli 2.3.0 release: I confirm that notifications works for me, just like Tusky. With Pachli battery optimization off and NTFY i receive every notifications, with battery optimization on i receive them once in a while or when i enter the app.
I didn't try without NTFY because i use many more apps in my phone with it and don't want to reset all the stuff :).

Thanks @nikclayton for your work!

@rluetzner
Copy link

Holy cow. I also just got my first actual Notification from Pachli after installing 2.3.0.
Thank you so much for your work. 🙂

@jumase
Copy link
Contributor

jumase commented Jun 10, 2024

I wanted to report that I'm also receiving pull notifications succesfully since version 2.3.0. Just to clarify, on previous versions pull notifications didn't work for me. And on version 2.5.2 they still work. Thanks!

@ghtux
Copy link

ghtux commented Jul 25, 2024

Notifications using push provider (ntfy/conversations) worked until there was a hikup with the provider. Now Pachlii log shows all accounts have a unifiedpush URL but can't be subscribed.
Error: retrofit2.http exception http 404.
Other apps like element e.g. don't have this issue.
A setting for reregister or notification options for push would be great.
It is not comfortable to log out and in for several accounts 😅

@nikclayton
Copy link
Contributor

Yep. I've started properly looking at the notification code and I think there are a number of things to change to make the user experience more seamless. I won't have any of this ready for 2.7.0 (coming next week) but it's top-of-mind for 2.8.0.

@nikclayton
Copy link
Contributor

This should be a lot more reliable from 2.8.0 onwards. @ghtux that includes being able to re-register with the UP distributor, and fixes to the UnifiedPush libraries.

https://pachli.app/pachli/2024/08/30/2.8.0-release.html describes situations where notifications might still be delayed.

I'll keep this open for a week or so for reports of other problems, then close if there's nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants