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

iOS App not receiving any notifations with 'Priority' set #461

Open
pinpox opened this issue Nov 1, 2022 · 9 comments
Open

iOS App not receiving any notifations with 'Priority' set #461

pinpox opened this issue Nov 1, 2022 · 9 comments
Labels
🪲 bug Something isn't working ios ntfy iOS app

Comments

@pinpox
Copy link

pinpox commented Nov 1, 2022

Not sure if it's a duplicate of #353, but the iOS app fails to receive any notications that have Priority set.
Example:
This is not received on my mobile phone

curl -u $NTFY_USER:$NTFY_PASS \                                                                                                                                 impure ❄ ntfy-sh
  -H 'Title: Backup on ahorn failed!' \
  -H 'Priority: high' \
  -H 'Tags: backup,borg,ahorn' \
  -d 'Backup error on ahorn: $exitStatus' 'https://push.pablo.tools/pinpox_backups'

While this works as expected:

curl -u $NTFY_USER:$NTFY_PASS \                                                                                                                                 impure ❄ ntfy-sh
  -H 'Title: Backup on ahorn failed!' \
  -H 'Tags: backup,borg,ahorn' \
  -d 'Backup error on ahorn: $exitStatus' 'https://push.pablo.tools/pinpox_backups'

I've tried different Priority values, they all seem to break the delivery on iOS. Subscribing to the topic via the CLI shows everything fine, it seems to be related to iOS.

@binwiederhier binwiederhier added 🪲 bug Something isn't working ios ntfy iOS app labels Nov 3, 2022
@binwiederhier
Copy link
Owner

  1. iOS is quite buggy, so I don't doubt that there could be issues. That said, the iOS priority is not adjusted in the Firebase message, so it would have to be on the iOS side.
  2. Are you behind Cloudflare? There is this ticket Ignore new HTTP Priority header #351 which could be related.
  3. Can you post the server logs with log-level: TRACE set? Just to rule out that this is a server-side issue?
  4. You could probably censor your hostname, unless you're ok with people knowing it.

@0x111
Copy link

0x111 commented Nov 13, 2022

I can confirm that this is happening in my case too. The desktop version displays both, while the ios app only the one without the priority flag.

ntfy version: ntfy 1.28.0 (d3cfa34), runtime go1.18.6, built at 2022-09-27T16:55:57Z

I did remove ip addresses and instance urls, but this is the Trace logs. I was sending a ntfy message from the same server where ntfy is running momentarily. I also used the same messages as provided by the OP.

2022/11/13 09:59:10 INFO Listening on 127.0.0.1:4456[http], ntfy 1.28.0, log level is TRACE
2022/11/13 09:59:15 DEBUG client-ipv6 HTTP POST /argus-uptime Dispatching request
2022/11/13 09:59:15 TRACE client-ipv6 HTTP POST /argus-uptime Entire request (headers and body):
POST /argus-uptime HTTP/1.1
User-Agent: curl/7.79.1
Accept-Encoding: gzip
X-Forwarded-Proto: https
Title: Backup on ahorn failed!
Connection: upgrade
Content-Length: 26
X-Forwarded-For: client-ipv6
Tags: backup,borg,ahorn
Authorization: Basic cnN6b2xhcjpXRm9kWFgyVnNDSnJMNXBlekxhaw==
Accept: */*
Priority: high
X-Real-Ip: [client-ipv6]:38176
Content-Type: application/x-www-form-urlencoded
X-Forwarded-Host: myntfy.instance.url

Backup error on ahorn: asd
2022/11/13 09:59:15 DEBUG client-ipv6/argus-uptime/pqbFMECX6iWT Received message: event=message, body=26 byte(s), delayed=false, firebase=true, cache=true, up=false, email=
2022/11/13 09:59:15 TRACE client-ipv6/argus-uptime/pqbFMECX6iWT Message body: {
  "id": "pqbFMECX6iWT",
  "time": 1668329955,
  "event": "message",
  "topic": "argus-uptime",
  "title": "Backup on ahorn failed!",
  "message": "Backup error on ahorn: asd",
  "priority": 4,
  "tags": [
    "backup",
    "borg",
    "ahorn"
  ]
}
2022/11/13 09:59:15 TRACE client-ipv6/argus-uptime/pqbFMECX6iWT No stream or WebSocket subscribers, not forwarding
2022/11/13 09:59:15 DEBUG client-ipv6/argus-uptime/pqbFMECX6iWT Publishing poll request to https://ntfy.sh/34046b5617ac98c39b8d8d601d3b5bcc6272ad8048136b64aa78f164e3834078
2022/11/13 09:59:18 DEBUG ipv4 HTTP GET /argus-uptime/json?poll=1&id=pqbFMECX6iWT Dispatching request
2022/11/13 09:59:18 TRACE ipv4 HTTP GET /argus-uptime/json?poll=1&id=pqbFMECX6iWT Entire request (headers and body):
GET /argus-uptime/json?poll=1&id=pqbFMECX6iWT HTTP/1.1
Connection: upgrade
Accept-Language: en-US,en;q=0.9
Authorization: Basic cnN6b2xhcjpXRm9kWFgyVnNDSnJMNXBlekxhaw==
X-Real-Ip: ipv4:14688
X-Forwarded-Host: myntfy.instance.url
Accept-Encoding: gzip, deflate, br
User-Agent: ntfy/1.2 (build 3; iOS 16.1.1)
Accept: */*
X-Forwarded-Proto: https
Priority: u=3
X-Forwarded-For: ipv4
2022/11/13 09:59:18 DEBUG ipv4 HTTP GET /argus-uptime/json?poll=1&id=pqbFMECX6iWT HTTP stream connection opened
2022/11/13 09:59:18 DEBUG ipv4 HTTP GET /argus-uptime/json?poll=1&id=pqbFMECX6iWT HTTP stream connection closed
2022/11/13 09:59:19 DEBUG desktop-ipv6 HTTP GET /argus-uptime/ws?since=OQYfhN2O687a&auth=QmFzaWMgY25ONmIyeGhjanBYUm05a1dGZ3lWbk5EU25KTU5YQmxla3hoYXc9PQ Dispatching request
2022/11/13 09:59:19 TRACE desktop-ipv6 HTTP GET /argus-uptime/ws?since=OQYfhN2O687a&auth=QmFzaWMgY25ONmIyeGhjanBYUm05a1dGZ3lWbk5EU25KTU5YQmxla3hoYXc9PQ Entire request (headers and body):
GET /argus-uptime/ws?since=OQYfhN2O687a&auth=QmFzaWMgY25ONmIyeGhjanBYUm05a1dGZ3lWbk5EU25KTU5YQmxla3hoYXc9PQ HTTP/1.1
Upgrade: websocket
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Accept-Encoding: gzip, deflate, br
Sec-Websocket-Version: 13
Connection: upgrade
Cache-Control: no-cache
Origin: https://myntfy.instance.url
Sec-Websocket-Extensions: permessage-deflate; client_max_window_bits
Accept-Language: en-US,en;q=0.9
Pragma: no-cache
X-Forwarded-Host: myntfy.instance.url
Sec-Gpc: 1
Sec-Websocket-Key: /l1c0jJQGTCMLdX10mhB/g==
X-Forwarded-For: desktop-ipv6
X-Forwarded-Proto: https
X-Real-Ip: [desktop-ipv6]:63881
2022/11/13 09:59:19 DEBUG desktop-ipv6 HTTP GET /argus-uptime/ws?since=OQYfhN2O687a&auth=QmFzaWMgY25ONmIyeGhjanBYUm05a1dGZ3lWbk5EU25KTU5YQmxla3hoYXc9PQ WebSocket connection opened

If you need more cooperation or logs @binwiederhier let me know, I am happy to help, because now any message with priority flag, does not pop up on my ios app which was apparently working for me until a few days ago.

Edit:
2. No cloudflare for me, although I use reverse proxy which I have set the flag as defined in docs
3. Done here
4. Done

@mpeterson
Copy link

I started to try ntfy today and notice issue is still prevalent almost a year after first reporting. I'm using it through cloudflare and can confirm that notifications with priority are never seen by the iOS client. I think this will make iOS user's adoption quite hard sadly, as it's harder to trust a system that doesn't work the way it should.

@binwiederhier
Copy link
Owner

@mpeterson ntfy is my side project. I work on the things that are fun for me, and of course I try to fix issues as they arise. I deployed a fix for the priority header issue as soon as I learned it was an issue as best I could. Apparently it doesn't work perfectly, but you can always use the X-Priority header instead and it should work just fine.

If you are not happy with a feature, you can always fork ntfy and fix it yourself. Complaining about it is certainly not helpful.

@mpeterson
Copy link

@binwiederhier sorry if I came across as rude. I didn't meant to complain, but clearly I chose a poor writing. I meant to raise awareness to the fact that this is still not working (as there haven't been many updates on the ticket) and that might make onboarding and getting traction of the project harder for iOS users.

What you've done is loable and I truly appreciate it, again sorry for my poor choice of wording.

@binwiederhier
Copy link
Owner

No worries. I am not an iOS user. I made the iOS app as best as I can, and there are many known issues. I have tried many many times to recruit iOS devs, without success.

I don't think this is an iOS issue though. I'm not sure though.

@Spyros-Amvrakidis
Copy link

Spyros-Amvrakidis commented Oct 12, 2023

Only for integration with Uptime Kuma and NTFY (Both behind Cloudflare)
I have rewrite Uptime Kuma Config to send only notifications without Priority

Here is the Config and the Custom Deployment for ntfy.js in Uptime Kuma

ConfigMap

`
apiVersion: v1
kind: ConfigMap
metadata:
name: ntfy-config
data:
ntfy.js: |
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { DOWN, UP } = require("../../src/util");

  class Ntfy extends NotificationProvider {

      name = "ntfy";

      /**
       * @inheritdoc
       */
      async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
          let okMsg = "Sent Successfully.";
          try {
              let headers = {};
              if (notification.ntfyAuthenticationMethod === "usernamePassword") {
                  headers = {
                      "Authorization": "Basic " + Buffer.from(notification.ntfyusername + ":" + notification.ntfypassword).toString("base64"),
                  };
              } else if (notification.ntfyAuthenticationMethod === "accessToken") {
                  headers = {
                      "Authorization": "Bearer " + notification.ntfyaccesstoken,
                  };
              }
              // If heartbeatJSON is null, assume non monitoring notification (Certificate warning) or testing.
              if (heartbeatJSON == null) {
                  let ntfyTestData = {
                      "topic": notification.ntfytopic,
                      "title": (monitorJSON?.name || notification.ntfytopic) + " [Uptime-Kuma]",
                      "message": msg,
                      "priority": 3,
                      "tags": [ "test_tube" ],
                  };
                  await axios.post(`${notification.ntfyserverurl}`, ntfyTestData, { headers: headers });
                  return okMsg;
              }
              let tags = [];
              let status = "unknown";
              let priority = notification.ntfyPriority || 4;
              if ("status" in heartbeatJSON) {
                  if (heartbeatJSON.status === DOWN) {
                      tags = [ "red_circle" ];
                      status = "Down";
                      // if priority is not 5, increase priority for down alerts
                      priority = priority === 5 ? priority : priority + 1;
                  } else if (heartbeatJSON["status"] === UP) {
                      tags = [ "green_circle" ];
                      status = "Up";
                  }
              }
              let data = {
                  "topic": notification.ntfytopic,
                  "message": heartbeatJSON.msg,
                  "priority": 3,
                  "title": monitorJSON.name + " " + status + " [Uptime-Kuma]",
                  "tags": tags,
                  "actions": [
                      {
                          "action": "view",
                          "label": "Open " + monitorJSON.name,
                          "url": monitorJSON.url,
                      }
                  ]
              };

              if (notification.ntfyIcon) {
                  data.icon = notification.ntfyIcon;
              }

              await axios.post(`${notification.ntfyserverurl}`, data, { headers: headers });

              return okMsg;

          } catch (error) {
              this.throwGeneralAxiosError(error);
          }
      }
  }

  module.exports = Ntfy;

`

Deployment just add this 2 Volumes

This is under
spec:
volumes:

`

  • name: ntfy
    configMap:
    name: ntfy-config
    `
    and this is under

containers:
volumeMounts:

`

  • name: ntfy
    mountPath: /app/server/notification-providers
    `

I know its not the best solution but it works
This config based on K3S and K8S infra but probably can work with some changes in docker compose etc
@binwiederhier if you can edit it to look normal please do that, as I can't put all configMap in same code block and I have write the volumes overwrite outside of code block as I try multiple times and it didn't join correctly in code block

@tcpsyn
Copy link

tcpsyn commented Nov 6, 2023

Another way to work around this is to use the Apprise notification handler in Uptime Kuma. ntfy:://server/topic or ntfys:://server/topic for ssl.

@binwiederhier
Copy link
Owner

The Priority header fix has been deployed for v2.8.0 (server) now. I re-read the ticket and I cannot make sense of it. We do not forward the Priority header to APNS when talking to the upstream server (ntfy.sh), and the header is in no way shape or form involved when fetching the notification from the selfhosted server.

I also manually tried it myself with a local server (not behind cloudflare obviously), and that also worked like a charm.

I am baffled how this should only affect iOS and nothing else.

If you use the X-Priority header instead of Priority, does that work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working ios ntfy iOS app
Projects
None yet
Development

No branches or pull requests

6 participants