[GH-ISSUE #337] iOS: Notifications received (in popup) but app interface doesn't update to reflect new notifications until manual refresh #262

Open
opened 2026-05-07 00:22:26 +02:00 by BreizhHardware · 5 comments

Originally created by @PiotrKrzyzek on GitHub (Jun 21, 2022).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/337

I successfully got the iOS app working and loading and receiving notifications, which is amazing and awesome. Though, I noticed that while it can receive notifications without issue the app interface in and of itself doesn't update 'live' when new notifications come in.

If I manually refresh (pull down refresh) it'll load them up just fine, but it won't do that by itself.

Expected behavior:

When a new notification is received, that topic's information should automatically update on the app interface.

Originally created by @PiotrKrzyzek on GitHub (Jun 21, 2022). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/337 I successfully got the iOS app working and loading and receiving notifications, which is amazing and awesome. Though, I noticed that while it can receive notifications without issue the app interface in and of itself doesn't update 'live' when new notifications come in. If I manually refresh (pull down refresh) it'll load them up just fine, but it won't do that by itself. Expected behavior: When a new notification is received, that topic's information should automatically update on the app interface.
Author
Owner

@binwiederhier commented on GitHub (Jun 21, 2022):

Hey thanks for using ntfy.

This is a known bug in iOS that I thought I had fixed in #267, but clearly not. I have the same problem sometimes with my iPhone but it doesn't always happen. I'll fix it eventually, but right now I'm a little bit clueless as to why this happens.

<!-- gh-comment-id:1161595133 --> @binwiederhier commented on GitHub (Jun 21, 2022): Hey thanks for using ntfy. This is a known bug in iOS that I thought I had fixed in #267, but clearly not. I have the same problem sometimes with my iPhone but it doesn't always happen. I'll fix it eventually, but right now I'm a little bit clueless as to why this happens.
Author
Owner

@PiotrKrzyzek commented on GitHub (Jun 21, 2022):

This may be presumptuous of me as someone who codes but hasn't coded in Swift (yet): it looks like it might be one of two things:

(a) receiving a notification isn't triggering a refresh (based upon the stuff I see from 267)
(b) a refresh is triggered but for the data only and not for the view/screen. So the data is updated there (somewhere), but it's not drawn / reflected into the screen.

For idea (b), this is from issues (usually caching related) I had with react and jquery. For idea (a) we've had similar logic issues on larger projects where we simply forgot to properly trigger a data pull in ALL places rather than just one.

Hopefully this gives me a good reason to try Swift finally and help out if I can.

Also, no worries about not making this a priority. I understand other items are more important. :)

You're doing awesome. Thank you much for this awesome app.

<!-- gh-comment-id:1161688288 --> @PiotrKrzyzek commented on GitHub (Jun 21, 2022): This may be presumptuous of me as someone who codes but hasn't coded in Swift (yet): it looks like it might be one of two things: (a) receiving a notification isn't triggering a refresh (based upon the stuff I see from 267) (b) a refresh is triggered but for the data only and not for the view/screen. So the data is updated there (somewhere), but it's not drawn / reflected into the screen. For idea (b), this is from issues (usually caching related) I had with react and jquery. For idea (a) we've had similar logic issues on larger projects where we simply forgot to properly trigger a data pull in ALL places rather than just one. Hopefully this gives me a good reason to try Swift finally and help out if I can. Also, no worries about not making this a priority. I understand other items are more important. :) You're doing awesome. Thank you much for this awesome app.
Author
Owner

@binwiederhier commented on GitHub (Jul 27, 2022):

So my guess is that this is caused by two things:

  1. The first message is received via Firebase/APNS and persisted to Core Data. Messages received via APNS run in the Notification Service Extension (NSE), not in the main app. They do, however, persist to the same Core Data database.
  2. The second message is received from the polling mechanism: Every 20 minutes or so, the app receives a "poll all topics" message on the internal ~poll topic. That will instruct the main app to poll for new messages. To find out the last message it received, it uses the lastNotificationId field and then polls using /mytopic/json?since=$id. This ID is coming from Core Data.

The issue is this (this is a GUESS!): The Core Data database is not properly in sync between the main app and the NSE, which means the lastNotificationId is out of sync, so messages are delivered/displayed twice. This is bug https://github.com/binwiederhier/ntfy/issues/316.

This causes another bug too, where the UI does not reflect all messages all the time (this is: https://github.com/binwiederhier/ntfy/issues/337). It is annoying and it just shows that I don't know how Core Data works internally. It could also be a bug, but it's annoying.

Again, this is just a guess.

Debugging this is next to impossible, because

  • (a) You'll have to compile and run the iOS app yourself and hook it up to Firebase and APNS. It doesn't work in a Simulator because Firebase doesn't work in a simulator.
  • (b) Because the NSE is a separate process, the logs for it do not show up in the log console of Xcode. You have to manually attach a debugger and such. It is surpremely annoying.

Before you ask "what the heck": 90% of this is Apple's fault, of how the NSE and all that work. The problem with Core Data is obviously my fault, but I have no time currently to debug this or spend any time with it.

<!-- gh-comment-id:1197486440 --> @binwiederhier commented on GitHub (Jul 27, 2022): So my guess is that this is caused by two things: 1. The first message is received via Firebase/APNS and persisted to Core Data. Messages received via APNS run in the Notification Service Extension (NSE), not in the main app. They do, however, persist to the same Core Data database. 2. The second message is received from the polling mechanism: Every 20 minutes or so, the app receives a "poll all topics" message on the internal ~poll topic. That will instruct the main app to poll for new messages. To find out the last message it received, it uses the `lastNotificationId` field and then polls using `/mytopic/json?since=$id`. This ID is coming from Core Data. The issue is this (this is a GUESS!): The Core Data database is not properly in sync between the main app and the NSE, which means the `lastNotificationId` is out of sync, so messages are delivered/displayed twice. This is bug https://github.com/binwiederhier/ntfy/issues/316. This causes another bug too, where the UI does not reflect all messages all the time (this is: https://github.com/binwiederhier/ntfy/issues/337). It is annoying and it just shows that I don't know how Core Data works internally. It could also be a bug, but it's annoying. Again, this is just a guess. Debugging this is next to impossible, because - (a) You'll have to compile and run the iOS app yourself and hook it up to Firebase and APNS. It doesn't work in a Simulator because Firebase doesn't work in a simulator. - (b) Because the NSE is a separate process, the logs for it do not show up in the log console of Xcode. You have to manually attach a debugger and such. It is surpremely annoying. Before you ask "what the heck": 90% of this is Apple's fault, of how the NSE and all that work. The problem with Core Data is obviously my fault, but I have no time currently to debug this or spend any time with it.
Author
Owner

@plia7 commented on GitHub (Jun 25, 2023):

Hello,

I can confirm having this issue too with my iPhone 12 Pro Max iOS 14.4.1.
Sometime it works when I receive the notification, when I click on it, it does take me to the app where the notification is showing without a manual refresh. But sometime it doesn't work without a manual refresh. If I'm already inside the app ui, and a new notification arrives, it doesn't reflect the new notification. I hope it can be fixed to make the functionality more consistent.

Thanks.

<!-- gh-comment-id:1605893200 --> @plia7 commented on GitHub (Jun 25, 2023): Hello, I can confirm having this issue too with my iPhone 12 Pro Max iOS 14.4.1. Sometime it works when I receive the notification, when I click on it, it does take me to the app where the notification is showing without a manual refresh. But sometime it doesn't work without a manual refresh. If I'm already inside the app ui, and a new notification arrives, it doesn't reflect the new notification. I hope it can be fixed to make the functionality more consistent. Thanks.
Author
Owner

@binwiederhier commented on GitHub (Nov 15, 2023):

📢 A new version of the ntfy iOS app is currently in TestFlight. This version (hopefully) fixes the issues with the UI not properly refreshing, as well as fixes for subscriptions "getting lost". It contains no other fixes. More to come. To test the app, please use this TestFlight link: https://testflight.apple.com/join/P1fFnAm9

<!-- gh-comment-id:1813327206 --> @binwiederhier commented on GitHub (Nov 15, 2023): :loudspeaker: A new version of the **ntfy iOS app** is currently in TestFlight. This version (hopefully) fixes the issues with the UI not properly refreshing, as well as fixes for subscriptions "getting lost". It contains no other fixes. More to come. To test the app, please use this TestFlight link: https://testflight.apple.com/join/P1fFnAm9
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#262
No description provided.