binwiederhier / ntfy

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

iOS not receiving push notifications (iPhone 15 Pro, iOS 17.0.2) #898

Open jacob-shuman opened 7 months ago

jacob-shuman commented 7 months ago

:lady_beetle: Describe the bug I've setup ntfy using docker compose and I am unable to receive push notifications.

:computer: Components impacted iOS App

:crystal_ball: Additional context For both the base url in the server.yml config as well as the default server in the iOS app I have tried using my local ip address both with and without the port (80) prefixed with http://. When I go into the app and subscribe to a topic manually refreshing the topic correctly shows me notifications for that topic. In my server.yml file I uncommented the upstream line for iOS users. I've noticed that when I try to send a test notification in the app and refresh the test notification does appear but a push notification is never sent (I'm not sure if this is intentional). I have enabled push notifications in the app (I do have scheduled summary for other apps but I enabled immediate delivery for the ntfy app).

Please let me know if there's any other information I can provide. Thank you for all of your hard work developing ntfy, it looks incredible and I'm excited to start using it!

chrismueller commented 7 months ago

For iOS you need to configure "https://ntfy.sh" as "upsteam-base-url" in your server.yml. See: iOS instant notifications for futher details.

Aspect13 commented 7 months ago

Same thing. But I use a different port for the app, if it matters (hopefully not). The ntfy is running in docker with ports "9876:80", so inside a container it is still listening on 80. For base-url and server address I set http://my.dns.com:9876. Message flow is working correctly, but pushes do not work.

ChokunPlayZ commented 7 months ago

I try to send a test notification in the app

yes it is intentional, the push notification will not be sent to the device that send the notification try running this in a terminal on other device you have, or send the test notification via the web interface it should trigger the push notification on your phone

curl -d "Hi" <your ntfy url>/<topic>
Aspect13 commented 7 months ago

the push notification will not be sent to the device that send the notification

Absolutely untrue. Try sending a test notification from the application clicking ... in top right corner -> Send test notification. My device (iOS) gets the notification afterwards. (No, I have not solved the issue with self-hosted servce, I used https://ntfy.sh server for this test case)

ChokunPlayZ commented 7 months ago

the push notification will not be sent to the device that send the notification

Absolutely untrue. Try sending a test notification from the application clicking ... in top right corner -> Send test notification. My device (iOS) gets the notification afterwards. (No, I have not solved the issue with self-hosted servce, I used https://ntfy.sh server for this test case)

I am able to get the notification now, not sure why I was able to reproduce what OP is saying earlier today I'm on a self hosted server and it works, I use a reverse proxy to expose the service

bvbeek commented 7 months ago

Same issue here, no push notifications

ctschach commented 7 months ago

Same happened to me, after I upgraded to and iPhone15….

Once I removed the ntfy app, deleted all data and then downloaded it again from the AppStore, confirmed that I want to receive messages, everything was working again as it should.

I assume that the restore/transfer messed up the internal push identifies…

Trystan34 commented 7 months ago

~I am still facing the same issue. I do not receive push notifications on iOS 17.0.1 nor on iOS 17.0.2 or iOS 17.0.3.~ If I refresh manually in the app, they do show up. I tried reinstalling as @ctschach suggested ~but still nothing unfortunately~.

I am also self hosting and modified config to use upsteam-base-url: https://ntfy.sh/

Similar to @Aspect13, I also use a different port on host as port 80 is being used by another service. The notifications work as expected on my domain on the desktop web browser with Cloudflare Tunnel.

Edit: I have fixed the issue and now receive notifications on iOS. It was a misconfiguration on my part. In your server.yml file: I had the base url set to local ip rather than my domain. ~base-url: 192.168.1.10~ -> base-url: https://exampledomain.com

Aspect13 commented 7 months ago

@Trystan34 I noticed that you have ssl setup. My server listens on 80 (http) not 443 (https) could this be the case? I'm still having the issue, my config seems to be fine in terms of base-url and upsteam-base-url

Trystan34 commented 7 months ago

@Aspect13 My server listens on port 8080 (http) not SSL but due to the one of the useful features of Cloud Flare, it provides a toggle for auto SSL encryption to the domain even though the actual NTFY server is listening on HTTP.

Originally I had my base-url set to the static ip of my Raspberry Pi but I did not receive the notifications, since changing it to my domain with https (even though I do not have HTTPS enabled in the ntfy server.yml) it works now.

image

My docker-compose file

version: "2.3"

services:
  ntfy:
    image: binwiederhier/ntfy
    container_name: ntfy
    command:
      - serve
    environment:
      - TZ=NZDT # optional: set desired timezone
    #user: 1000:1000 # optional: replace with your own user/group or uid/gid
    volumes:
      - /var/cache/ntfy/cache.db:/var/cache/ntfy
      - /etc/ntfy:/etc/ntfy
    ports:
      - "8080:80"
    restart: always

Since the Cloud Flare Tunnel points to my static ip of the Raspberry PI including port 8080, in the iOS app, I have the server set to just domain name excluding the port number. Also, in the server.yml the base-url does not include the port.

jamesscottbrown commented 7 months ago

Same happened to me, after I upgraded to and iPhone15….

Once I removed the ntfy app, deleted all data and then downloaded it again from the AppStore, confirmed that I want to receive messages, everything was working again as it should.

I assume that the restore/transfer messed up the internal push identifies…

Ditto: after migrating to a new iPhone using Quick Start transfer push notifications didn't work on the new phone, but after deleting and re-installing the app they worked again.

mikekuzak commented 5 months ago

Using Docker Env variables should work too, right ?

 ntfy:
    image: binwiederhier/ntfy:${NTFY_VERSION}
    container_name: ntfy
    command:
      - serve
    environment:
        TZ: "Europe/London"
        NTFY_BASE_URL: "https://${NTFY_FQDN}"
        NTFY_UPSTREAM_BASE_URL: "https://ntfy.sh" # Needed for iOS to work
        NTFY_CACHE_FILE: "/var/cache/ntfy/cache.db"
        NTFY_BEHIND_PROXY: "true"
        NTFY_AUTH_FILE: "/var/cache/ntfy/user.db"
        NTFY_AUTH_DEFAULT_ACCESS: "deny-all"
        NTFY_USER: ${NTFY_USER}
        NTFY_ATTACHMENT_CACHE_DIR: "/var/cache/ntfy/attachments"
        NTFY_WEB_ROOT: "disable"
    user: 1000:1000 # optional: replace with your own user/group or uid/gid
emiwirs commented 5 months ago

I have been trying to find out for days what my notification/alert problem caused , but for me it was rather straight forward. I am using an add blocker (a PiHole) which blocks the firebase URL “firebaselogging-pa.googleapis.com”. Once whitelisting this one, it solved all my problems… 😬. So pay attention to any dns filtering, hopefully this helps someone!

mikekuzak commented 5 months ago

So just that I understand this correctly, on the Nfty server:

        NTFY_BASE_URL: "https://myntfy.com"
        NTFY_UPSTREAM_BASE_URL: "https://ntfy.sh" 

What are the settings on the ios app ? Default server: https://ntfy.sh but when you add topic you specify your server https://myntfy.com topic lets say: 'test' ?

emiwirs commented 5 months ago

That is mostly correct, only difference is default server is myntfy.com on iOS. Environment: ntfy in docker, traefik for exposing through ssl, iOS en iPadOS devices, working server.yml file

Tested:

All of the above (plus switching default servers) do get the test messages through on the iOS devices after pulling down, forcing refresh, in the apps. However, the notifications simply didn’t get through at all.

Switching off PiHole filtering made the notifications for new messages appear instantly (depending on the priority of the test messages, low priority I didn’t wait for, but 3 default prio or higher, direct results). Blocking off the firebase url was occurring when PiHole was switched on again.

Self hosting problem? No, I also used a fresh app install and only defined ntfy.sh/mytopic, same problem. And now also solved.

mikekuzak commented 5 months ago

well my confusion here is statement from the author:

The upstream-base-url must be configured to match exactly what you have configured as a default base URL in your iOS app. Otherwise messages will not arrive at all. See https://docs.ntfy.sh/config/#ios-instant-notifications

So my understanding is that if you point NTFY_UPSTREAM_BASE_URL: "https://ntfy.sh" (as suggested)

in the iOS you also have to set the base URL to "https://ntfy.sh"

unless I get this totally wrong.

emiwirs commented 5 months ago

I read it the same as you do, but for me it isn’t a requirement…

Some more test results:

There is some activation/enabling/registration happening, as once it is working, it continues to work: 1 iOS device I didn’t change/touch during the testing and that one continues to receive all notifications during testing. I will also check over a longer period whether it is related to some dns caching…

So, at this moment, I am sure it is related to the following 4 URL’s (all of them or any combination of them):

wunter8 commented 5 months ago

well my confusion here is statement from the author:

The upstream-base-url must be configured to match exactly what you have configured as a default base URL in your iOS app. Otherwise messages will not arrive at all. See https://docs.ntfy.sh/config/#ios-instant-notifications

So my understanding is that if you point NTFY_UPSTREAM_BASE_URL: "https://ntfy.sh" (as suggested)

in the iOS you also have to set the base URL to "https://ntfy.sh"

unless I get this totally wrong.

Where did you see that? The default server in iOS needs to exactly match base-url on the server, not upstream-base-url. Make sure they both have https:// and that neither has a trailing /

(See https://docs.ntfy.sh/known-issues/#ios-app-not-receiving-notifications-anymore)

mikekuzak commented 5 months ago

@wunter8 https://github.com/binwiederhier/ntfy/issues/880#issuecomment-1828949447

wunter8 commented 5 months ago

Got it. I'm pretty sure that was a typo. The link I included to the docs says what I said:

Ensure that the URL you set in base-url matches exactly what you set the Default Server in iOS to

roemer2201 commented 5 months ago

I had the same issue as OP, but thanks to this thread, I was able to solve it: My base-url was http://ntfy.example.com (note the missing "s" at "http"). Other set options are listen-http: "localhost:8080", behind-proxy: true. As you can see, my server is configured to run on localhost:8080 without https. Now my apache2 is configured as virtual host for my ntfy.example.com, listening on port 80 and 443, forwarding requests from 80 to 443 (I got this configuration from the documentation) and talking to the service over localhost:8080.

Leaving the "s" in my base-url made the server work basically, but no iOS push was working. So I tried adding the "s" to the base-url and voila ... iOS push is working!

omgprod commented 5 months ago

I had the same issue as OP, but thanks to this thread, I was able to solve it: My base-url was http://ntfy.example.com (note the missing "s" at "http"). Other set options are listen-http: "localhost:8080", behind-proxy: true. As you can see, my server is configured to run on localhost:8080 without https. Now my apache2 is configured as virtual host for my ntfy.example.com, listening on port 80 and 443, forwarding requests from 80 to 443 (I got this configuration from the documentation) and talking to the service over localhost:8080.

Leaving the "s" in my base-url made the server work basically, but no iOS push was working. So I tried adding the "s" to the base-url and voila ... iOS push is working!

Hello there ! can you share your conf files : docker-compose.yml, server.yml and nginx conf file ?

roemer2201 commented 5 months ago

Hello there ! can you share your conf files : docker-compose.yml, server.yml and nginx conf file ?

I'm running it on a Linux VPS, no docker or anything, here are the confs used:

$ cat /etc/apache2/sites-available/ntfy.conf
<VirtualHost *:80>
    ServerName ntfy.example.com

    # Proxy connections to ntfy (requires "a2enmod proxy proxy_http")
    ProxyPass / http://127.0.0.1:8080/ upgrade=websocket
    ProxyPassReverse / http://127.0.0.1:8080/

    SetEnv proxy-nokeepalive 1
    SetEnv proxy-sendchunked 1

    # Higher than the max message size of 4096 bytes
    LimitRequestBody 102400

    # Redirect HTTP to HTTPS, but only for GET topic addresses, since we want
    # it to work with curl without the annoying https:// prefix (requires "a2enmod alias")
    <If "%{REQUEST_METHOD} == 'GET'">
        RedirectMatch permanent "^/([-_A-Za-z0-9]{0,64})$" "https://%{SERVER_NAME}/$1"
    </If>

</VirtualHost>

<VirtualHost *:443>
    ServerName ntfy.example.com

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/example.com_ssl_certificate.cer
    SSLCertificateKeyFile /etc/apache2/ssl/_.example.com_private_key.key

    # Proxy connections to ntfy (requires "a2enmod proxy proxy_http")
    ProxyPass / http://127.0.0.1:8080/ upgrade=websocket
    ProxyPassReverse / http://127.0.0.1:8080/

    SetEnv proxy-nokeepalive 1
    SetEnv proxy-sendchunked 1

    # Higher than the max message size of 4096 bytes
    LimitRequestBody 102400

</VirtualHost>
$ egrep -v '(^#|^$)' /etc/ntfy/server.yml
base-url: https://ntfy.example.com
listen-http: "localhost:8080"
auth-file: /var/lib/ntfy/user.db
auth-default-access: "deny-all"
behind-proxy: true
upstream-base-url: "https://ntfy.sh"
omgprod commented 5 months ago

Thank’s @roemer2201 I whish this will helps, I found my way just on turning my firewall rules down from the web hosting service, I have to dig it more for the moment. Hope this can helps. If requested I can share my conf I’m using docker compose, nginx.

I supposed the Poll request getting blocked ..

bryanperez43 commented 1 month ago

How i get Life Notifications

version: "3"

services:
  ntfy:
    image: binwiederhier/ntfy
    container_name: ntfy
    command:
      - serve
    environment:
      TZ: "America/New_York"
      NTFY_BASE_URL: "http://{ip}:8080"
      NTFY_UPSTREAM_BASE_URL: "https://ntfy.sh"
    volumes:
      - /var/cache/ntfy:/var/cache/ntfy
      - /etc/ntfy:/etc/ntfy
    ports:
      - "8080:80"
    restart: always

on IOS ntfy app

  1. go to settings
  2. change default server to match NTFY_BASE_URL
  3. subscribe to a topic
  4. you now get live notifications