Giter VIP home page Giter VIP logo

Comments (13)

MichalNemec avatar MichalNemec commented on September 18, 2024

Why was this closed? i just encountered the same issue, because i updated to v14.
can someone explain why that happens?

from sygnal.

devonh avatar devonh commented on September 18, 2024

Would you be able to try changing the fcm_options config to use the following?

 fcm_options:
    apns:
      payload:
        aps:
          content-available: 1
          mutable-content: 1
          alert: ""

The new FCM api removed the top level APNS convenience fields and instead prefers them to be specifically declared inside of an apns block within the payload.
The alert field may or may not be necessary. There are various reports around the internet about it helping in some cases. I just don't have access to a convenient iOS setup to test it out right now.

If that works I can update the documentation to match.

from sygnal.

MichalNemec avatar MichalNemec commented on September 18, 2024
2024-04-08 21:50:56,705 [1] ERROR sygnal.http [8e1ff690-3ed5-4ac6-9b91-45643db56bea] Exception whilst dispatching notification.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/sygnal/http.py", line 275, in _handle_dispatch
    result = await pushkin.dispatch_notification(notif, d, context)
  File "/usr/local/lib/python3.10/site-packages/sygnal/notifications.py", line 217, in dispatch_notification
    return await self._dispatch_notification_unlimited(n, device, context)
  File "/usr/local/lib/python3.10/site-packages/sygnal/gcmpushkin.py", line 520, in _dispatch_notification_unlimited
    data = GcmPushkin._build_data(n, device, self.api_version)
  File "/usr/local/lib/python3.10/site-packages/sygnal/gcmpushkin.py", line 673, in _build_data
    for attr, value in data["content"].items():
AttributeError: 'NoneType' object has no attribute 'items'
2024-04-08 21:50:57,669 [1] DEBUG sygnal.gcmpushkin [215c0bd6-5792-496c-99f8-2d98f3f0e3c1] GCM request took 0.107985 seconds
2024-04-08 21:50:57,669 [1] ERROR sygnal.gcmpushkin [215c0bd6-5792-496c-99f8-2d98f3f0e3c1] 400 from server, we have sent something invalid! Error: '{\n  "error": {\n    "code": 400,\n    "message": "Request contains an invalid argument.",\n    "status": "INVALID_ARGUMENT",\n    "details": [\n      {\n        "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",\n        "errorCode": "INVALID_ARGUMENT"\n      },\n      {\n        "@type": "type.googleapis.com/google.rpc.BadRequest",\n        "fieldViolations": [\n          {\n            "field": "message.token",\n            "description": "Invalid registration token"\n          }\n        ]\n      }\n    ]\n  }\n}\n'
2024-04-08 21:50:57,670 [1] WARNING sygnal.http [215c0bd6-5792-496c-99f8-2d98f3f0e3c1] Failed to dispatch notification.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/sygnal/http.py", line 275, in _handle_dispatch
    result = await pushkin.dispatch_notification(notif, d, context)
  File "/usr/local/lib/python3.10/site-packages/sygnal/notifications.py", line 217, in dispatch_notification
    return await self._dispatch_notification_unlimited(n, device, context)
  File "/usr/local/lib/python3.10/site-packages/sygnal/gcmpushkin.py", line 574, in _dispatch_notification_unlimited
    new_failed, new_pushkeys = await self._request_dispatch(
  File "/usr/local/lib/python3.10/site-packages/sygnal/gcmpushkin.py", line 287, in _request_dispatch
    return self._handle_v1_response(
  File "/usr/local/lib/python3.10/site-packages/sygnal/gcmpushkin.py", line 431, in _handle_v1_response
    raise NotificationDispatchException("Invalid request")
sygnal.exceptions.NotificationDispatchException: Invalid request

did exactly this:

com.example.app:
    type: gcm
    api_version: v1
    project_id: projectID
    service_account_file: path/json
    fcm_options:
      apns:
        payload:
          aps:
            content_available: 1
            mutable_content: 1
            alert: ""

if i comment out entire fcm_options, its without any error.

from sygnal.

devonh avatar devonh commented on September 18, 2024

Ah - that issue was fixed in #362. I'll make a new release with the fix, and then the new config changes I mentioned should work.

from sygnal.

devonh avatar devonh commented on September 18, 2024

Would you be able to try with the 0.14.1 release?

from sygnal.

railsmechanic avatar railsmechanic commented on September 18, 2024

For me, it doesn't work either with version 0.14.1. Despite various attempts to configure content-available, in all the ways mentioned, the setup fails consistently, resulting in the following error message:

"Invalid JSON payload received. Unknown name \"content-available\" at 'message.data[0].value': Cannot find field."

Are there any other suggestions on how to configure it? We need the content-available setting to be True or 1 for our application to work correctly. We also need to use firebase for sending push notifications. Any ideas? 🤷‍♂️

from sygnal.

devonh avatar devonh commented on September 18, 2024

For me, it doesn't work either with version 0.14.1. Despite various attempts to configure content-available, in all the ways mentioned, the setup fails consistently, resulting in the following error message:

"Invalid JSON payload received. Unknown name \"content-available\" at 'message.data[0].value': Cannot find field."

Are there any other suggestions on how to configure it? We need the content-available setting to be True or 1 for our application to work correctly. We also need to use firebase for sending push notifications. Any ideas? 🤷‍♂️

Would you be able to specify what your config looks like? I can't seem to reproduce that particular error you are seeing.

from sygnal.

railsmechanic avatar railsmechanic commented on September 18, 2024

Would you be able to specify what your config looks like? I can't seem to reproduce that particular error you are seeing.
This is the relevant part of the configuration, but I have already tested several variants:

apps:
  com.app.my:
    api_version: v1
    project_id: my-app
    service_account_file: /sygnal/my-app-firebase-adminsdk-sq3l9-deea15e111.json
    type: gcm
    fcm_options:
      apns:
        payload:
          aps:
            content-available: 1

from sygnal.

devonh avatar devonh commented on September 18, 2024

hmm. Could you send the full log message from sygnal?

from sygnal.

railsmechanic avatar railsmechanic commented on September 18, 2024

This error is returned by sygnal:

2024-05-30 06:25:37,867 [1] INFO  sygnal.access Handled request: "10.42.14.209" - - [30/May/2024:06:25:37 +0000] "POST /_matrix/push/v1/notify HTTP/1.1" 502 - "-" "Synapse/1.105.1"
2024-05-30 06:25:54,162 [1] INFO  sygnal.gcmpushkin [6e5ec94f-acd7-4721-9e39-159404c20bcb] Sending (attempt 0) => ['<redacted>:<redacted>'] room:!ZygeAnECWdnSEuBfis:matrix.my-server.com, event:$veG0pHl06n55JIJwbhIpdlZXEiOd-gi8MjqPrunvSak
2024-05-30 06:25:54,272 [1] ERROR sygnal.gcmpushkin [6e5ec94f-acd7-4721-9e39-159404c20bcb] 400 from server, we have sent something invalid! Error: '{\n  "error": {\n    "code": 400,\n    "message": "Invalid JSON payload received. Unknown name \\"alert\\" at \'message.data[0].value\': Cannot find field.\\nInvalid JSON payload received. Unknown name \\"content-available\\" at \'message.data[0].value\': Cannot find field.\\nInvalid JSON payload received. Unknown name \\"mutable-content\\" at \'message.data[0].value\': Cannot find field.",\n    "status": "INVALID_ARGUMENT",\n    "details": [\n      {\n        "@type": "type.googleapis.com/google.rpc.BadRequest",\n        "fieldViolations": [\n          {\n            "field": "message.data[0].value",\n            "description": "Invalid JSON payload received. Unknown name \\"alert\\" at \'message.data[0].value\': Cannot find field."\n          },\n          {\n            "field": "message.data[0].value",\n            "description": "Invalid JSON payload received. Unknown name \\"content-available\\" at \'message.data[0].value\': Cannot find field."\n          },\n          {\n            "field": "message.data[0].value",\n            "description": "Invalid JSON payload received. Unknown name \\"mutable-content\\" at \'message.data[0].value\': Cannot find field."\n          }\n        ]\n      }\n    ]\n  }\n}\n'
2024-05-30 06:25:54,272 [1] WARNING sygnal.http [6e5ec94f-acd7-4721-9e39-159404c20bcb] Failed to dispatch notification.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/sygnal/http.py", line 275, in _handle_dispatch
    result = await pushkin.dispatch_notification(notif, d, context)
  File "/usr/local/lib/python3.10/dist-packages/sygnal/notifications.py", line 217, in dispatch_notification
    return await self._dispatch_notification_unlimited(n, device, context)
  File "/usr/local/lib/python3.10/dist-packages/sygnal/gcmpushkin.py", line 574, in _dispatch_notification_unlimited
    new_failed, new_pushkeys = await self._request_dispatch(
  File "/usr/local/lib/python3.10/dist-packages/sygnal/gcmpushkin.py", line 287, in _request_dispatch
    return self._handle_v1_response(
  File "/usr/local/lib/python3.10/dist-packages/sygnal/gcmpushkin.py", line 431, in _handle_v1_response
    raise NotificationDispatchException("Invalid request")
sygnal.exceptions.NotificationDispatchException: Invalid request

from sygnal.

devonh avatar devonh commented on September 18, 2024

This error is returned by sygnal:
...

Ok. So based off that error, I assume that you have specified something like this when calling POST /_matrix/client/r0/pushers/set:

"data": {
  "default_payload": {
    "aps": {
      "mutable-content": 1,
      "content-available": 1,
      "alert": {"loc-key": "SINGLE_UNREAD", "loc-args": []}
    }
  }
}

Sygnal takes that, and adds it into the message.data key of the FCM v1 notification.
This is what is causing the INVALID_ARGUMET error.

Removing the aps section from the default_payload should fix your issue.

from sygnal.

railsmechanic avatar railsmechanic commented on September 18, 2024

When removing the aps section it works with "silent notifications", only when the app is in foreground, but we need the "background update notification", which wakes up the app to process the notification.

Does the "content-available": 1 have to be set by calling POST - /_matrix/client/r0/pushers/set or in the configuration?

from sygnal.

devonh avatar devonh commented on September 18, 2024

When removing the aps section it works with "silent notifications", only when the app is in foreground, but we need the "background update notification", which wakes up the app to process the notification.

Does the "content-available": 1 have to be set by calling POST - /_matrix/client/r0/pushers/set or in the configuration?

None of the aps config should be set using POST - /_matrix/client/r0/pushers/set when sending iOS notifications using the Firebase v1 API. Currently in sygnal, it should all be set using the config file. Using /pushers/set to configure aps will lead to INVALID_ARGUMENT errors from firebase in this scenario.

As for the issue with "silent notifications", I have found these two issues that contain potential workarounds.
https://stackoverflow.com/questions/37570200/firebase-silent-apns-notification/56165642#56165642
https://stackoverflow.com/questions/19239737/silent-push-notification-in-ios-7-does-not-work/

If you can try some of those suggestions out, I would very much appreciate an update on whether some combination of those configuration settings make things work.
Then I can update our documentation with suggested config setup.

from sygnal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.