binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.54k stars 729 forks source link

No more IOS push notification since July 2024 #1191

Open GuillaumeDebernard opened 1 month ago

GuillaumeDebernard commented 1 month ago

Quick description

I have NTFY running with docker-compose, behind an nginx reverse-proxy with https (certbot). Since mid-July, I no longer receive notifications on IOS, which used to work fine.

The requests I send look like : curl -d Hello https://ntfy.myDomain.com/myTopic.

Note that reverse-proxy is used for other services and work perfectly fine for them.

I didn't see any trace log about usage limits.

What's still working

What I tried, and didn't work

My configurations

docker-compose.yaml file

ntfy:
  image: binwiederhier/ntfy:latest
  container_name: ntfy_container
  command:
    - serve
  environment:
    TZ: "Europe/Paris"
    NTFY_BASE_URL: https://${SUB_NTFY}
    NTFY_LISTEN_HTTP: :${NTFY_PORT}
    NTFY_CACHE_FILE: /var/cache/ntfy/cache.db
    NTFY_ATTACHMENT_CACHE_DIR: /var/cache/ntfy/attachments
    NTFY_UPSTREAM_BASE_URL: https://ntfy.sh
    NTFY_LOG_LEVEL: warning
    NTFY_LOG_FORMAT: text
    NTFY_LOG_FILE: var/ntfy/logs.log
    NTFY_KEEPALIVE_INTERVAL: 45s
    NTFY_BEHIND_PROXY: true
    NTFY_WEB_ROOT: /app
  volumes:
    - ./utils/ntfy/cache:/var/cache/ntfy
    - ./utils/ntfy:/var/ntfy
  ports:
    - "${NTFY_PORT}:${NTFY_PORT}"
   # Work the same if using port 80
  networks:
    - main

Nginx default.conf.template file

server {
  listen ${HTTPS_DEFAULT} ssl http2;
  listen [::]:${HTTPS_DEFAULT} ssl http2;

  server_name ${SUB_NTFY};

  ssl_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/${DOMAIN}/privkey.pem;

  set $upstream_ntfy "ntfy:${NTFY_PORT}";

  resolver 127.0.0.11 valid=1m;

  location / {

    rewrite /(.*) /$1 break;
    proxy_pass http://$upstream_ntfy/$1$is_args$args;
    proxy_http_version 1.1;

    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_connect_timeout 3m;
    proxy_send_timeout 3m;
    proxy_read_timeout 3m;

    client_max_body_size 0;
  }
}

What i really don't understand is why it stopped working. I should have read a hundred times all the configuration page from ntfy.sh without finding any problems in my configuration.
Since I didn't see any new post about that issue I assumed it was an nginx configuration issue, but every other services I host, and ntfy usage (webapp, android) are still working. I upgrade recently IOS 17 to 18 without any improvement.

I'm running out of ideas, if anyone is facing the same issue, join the club ;)

I'd also like to take this opportunity to congratulate you on your great work!

a1ad commented 1 month ago

Yeah, same here

plittlefield commented 1 month ago

I’ve just installed the docker ntfy behind a Traefik proxy with password user logins and a topic called with an API.

It all works but I’m not getting any iOS notifications - UNLESS I go in to the app and pull down to refresh.

What am I doing wrong or is this a deal breaking bug?!

Thanks.

wunter8 commented 1 month ago

In general, notifications to iOS are tricky. I haven't heard anything specific about updates to iOS 18 or Nginx causing problems, though. It's definitely strange that things were working and then stopped (at least for OP).

You'll have better luck with notifications on iOS through the PWA. You'll need to set up web push keys on your self-hosted server (and have the server behind a domain with a TLS cert that is publicly trusted (e.g., not self-signed)), but it's easy to set up. With the PWA, notifications should arrive reliably, and you'll have more features than the native iOS app (like markdown formatting and embedded image previews).

Here's the list of things I tell people to do to get iOS notifications working, so you can double-check that everything is in order (but again, if it was working and stopped without any sort of config change, I don't know what would cause that):

  1. open a browser to the web app of your ntfy instance and copy the URL (including "http://" or "https://", your domain or IP address, and any ports, and excluding any trailing slashes)
  2. put the URL you copied in the ntfy base-url config in server.yml or NTFY_BASE_URL in env variables
  3. put the URL you copied in the default server URL setting in the iOS ntfy app
  4. set upstream-base-url in server.yml or NTFY_UPSTREAM_BASE_URL in env variables to "https://ntfy.sh"
plittlefield commented 1 month ago

Wow, very detailed reply many thanks.

I will try that tomorrow and report back.

plittlefield commented 1 month ago

Hi @wunter8 I have news.

The addition of the variable NTFY_UPSTREAM_BASE_URL to my docker-compose.yml now makes a Notification appear in the Notification Centre of my iPhone.

However, this is still not quite good enough for me, because I need it to appear on the Lock Screen ... just like Pushover does.

Also, what is PWA ?

plittlefield commented 1 month ago

OK, I take that back!

I have just received a ntfy notification on my lock screen and my watch!

Happy days!

a1ad commented 1 month ago

@plittlefield with the app from the store? Mine is still not working

@wunter8 can we use "server.yml" and the docker ENVs at the same time?

plittlefield commented 1 month ago

@a1ad yes.

Here is my redacted docker compose file ...

https://pastebin.com/raw/TjEiyaZs

wunter8 commented 1 month ago

@a1ad I think it's okay to use server.yml and env variables simultaneously, but I'm not certain which would take priority if there were conflicts. Probably the env variables. I'd recommend just using one or the other, though, to avoid complicating things

The PWA (Progressive Web App) allows you to install the web app as a standalone app on your phone. It can still receive notifications in the background (on iOS >= 16.4), has more features than the native app (like markdown support), and has more reliable notifications. To self host the PWA, you need to configure web push keys (https://docs.ntfy.sh/config#web-push)

plittlefield commented 1 month ago

OK, I might try that tomorrow.

What do I have to install on the phone for this work or does it just use the existing iOS app?

wunter8 commented 1 month ago

After setting up the web push keys, load the self-hosted web app in Safari and then go to Share > "add to homescreen"

plittlefield commented 1 month ago

Blimey, I did not know about that and I've had an iPhone for 5 years :-)

plittlefield commented 1 month ago

Oooo, will that give me nice count badges?!

wunter8 commented 1 month ago

Background notifications for PWAs on iOS have only been supported since iOS 16.4 (March 2023).

I'm not sure about the count badges 🤷‍♂️ (I don't use iOS)

plittlefield commented 1 month ago

image

wunter8 commented 1 month ago

Oh, I know what they are. I just don't know if PWAs support it in general. And I don't know if the ntfy PWA supports them specifically.

(Or were you showing us the ntfy app doesn't have a badge meaning they're apparently not supported? I also can't tell if that's the ntfy app or the ntfy PWA)

plittlefield commented 1 month ago

A bit of both - showing you the unread badge count on WhatsApp and that ntfy does not support that feature yet.

plittlefield commented 1 month ago

Web push configured and seems to be OK but after putting the Safari bookmark on the iOS home screen (and then a login to my ntfy account) I no only do not get new notifications but also no unread badges.

Oh well.

I shall stick to the actual app for now.

plittlefield commented 1 month ago

I’m trying Chrome on iOS as well - it shows the notice about adding notifications - IMG_1493

wunter8 commented 1 month ago

When you click on the ntfy-web icon on your homescreen, does it just load the web app in Safari or does it launch a PWA in a standalone screen (without the Safari URL bar on top and stuff)?

plittlefield commented 1 month ago

I think it’s a PWA … what do you think?

IMG_1496

IMG_1497

… getting there, but of course it’s the actual iOS app that’s showing me notifications on my “Notification Centre” and not the web app.

At least I think so!

Did you want me to uninstall the actual App to see ?

wunter8 commented 1 month ago

Yes, that looks like the PWA. You could try uninstalling the native app. No reason not to try that

plittlefield commented 1 month ago

Okay, that's uninstalled ... drum roll for later today :-)

plittlefield commented 1 month ago

Well blow me down with a feather!

IMG_1506

svewag commented 3 weeks ago

I can confirm that the notifications on iOS are working just fine in the PWA, but not in the app.

chlorine3545 commented 3 weeks ago

@wunter8 Sorry to interrupt. What is NTFY_UPSTREAM_BASE_URL? Do notifications from our self-hosted server need to be forwarded to the official ntfy server?

Also, if I may ask politely, is it because the official ntfy server has APNS configured, whereas our self-hosted server does not?

I'm a novice in this area, so apologies for any mistakes.

wunter8 commented 3 weeks ago

@chlorine3545 You are correct. Here's some info: https://docs.ntfy.sh/config/#ios-instant-notifications

Let me know if you have more questions

chlorine3545 commented 3 weeks ago

First of all, thanks for your reply @wunter8.

Not only Ntfy, but all these unified push can't work properly on iOS, we have to use APNs, which is a shame to some extent. Maybe I should get an Android phone and flash it with LineageOS or something.

lbeier commented 2 weeks ago

Hey folks! First of all, thanks for this amazing project! 🥇

I'm also having issues with iOS push notifications. I've set both base-url and upstream-base-url and I believe they are correct.

Not sure what else I'm missing though. It's likely be something really stupid, but I can't really understand what it is.

Here is my docker-compose.yml:

version: "2.1"
services:
  ntfy:
    image: binwiederhier/ntfy:latest
    container_name: ntfy
    command:
      - serve
    environment:
      - TZ=Europe/Madrid
    volumes:
      - lib:/var/lib/ntfy
      - config:/etc/ntfy
    ports:
      - 31209:80 # I have something else running on port 80, so I generated a random port for host
    restart: unless-stopped
    labels:
      - "com.centurylinklabs.watchtower.enable=true"

volumes:
  lib: {}
  config: {}

And here is my server.yml:

base-url: "https://ntfy.<MY-HOMELAB-HOST>"
upstream-base-url: "https://ntfy.sh"

auth-file: "/var/lib/ntfy/auth.db"
auth-default-access: "deny-all"
enable-login: true

behind-proxy: true

cache-file: "/var/lib/ntfy/cache.db"

attachment-cache-dir: "/var/lib/ntfy/attachments"
attachment-total-size-limit: "5G"
attachment-file-size-limit: "15M"
attachment-expiry-duration: "3h"
visitor-attachment-total-size-limit: "100M"
visitor-attachment-daily-bandwidth-limit: "500M"

Some additional info that might be relevant:

lbeier commented 2 weeks ago

So, I've installed the NTFY app on my iPad and the notifications are working on the iPad.

Both iPhone and iPad are in public beta.

iOS 18.1 (22B83) iPadOS 18.1 (22B82)

There was a pending update on my iPad. Just installed it (iPadOS 18.1 (22B83)) and the notifications are still working.

The issue seems to be isolated to iOS only. 🤔

wunter8 commented 2 weeks ago

Hmm. I haven't heard of someone having issues on iOS but not on iPadOS. That seems to suggest your ntfy server is configured correctly. I've heard some people say reinstalling the ntfy app can help. But I'm not sure what else to try.

I generally recommend people use the PWA on iOS, though. It has more features than the native app and more reliable notifications. You need to configure web push to get it to work: https://docs.ntfy.sh/config#web-push

lbeier commented 2 weeks ago

Hey @wunter8!

Thanks for the suggestion! I've setup and I'm getting notifications on the pwa now.

Will still investigate a bit mor about the iOS specific issue and get back here if I find something. But for now, the pwa is working just fine.

plittlefield commented 2 weeks ago

I'd like to chime in and say that while the PWA is working great, there does not seem to be a synchronisation between the PWA app running on my phone and the web site in a browser tab.

What I mean by this is that when I get a notification it appears on both devices, BUT when I read or read and delete from either of the devices, the other device does not appear the same ... indeed all notifications remain UNREAD.

wunter8 commented 2 weeks ago

@plittlefield That is the expected behavior right now. The state of individual messages is not synchronized between devices/clients

plittlefield commented 2 weeks ago

Oh, okay!

soffio commented 2 weeks ago

I set up a self-hosted a few days ago and it worked fine. But yesterday I couldn't receive notifications anymore. Today I reinstalled the app and it worked again. It's so weird.