-
Notifications
You must be signed in to change notification settings - Fork 153
Use default_payload
in Push Payloads
#127
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ismailgulek, I've got a few questions I'm afraid...
changelog.d/127.feature
Outdated
@@ -0,0 +1 @@ | |||
Add fallback_content handling from push data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you try to expand on this a bit? What is fallback_content? what does handling
it involve? does this affect both iOS and Android, or just one of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, fallback_content
is needed because we need to add alert
in the aps
field of payload. The handling is this: if we see this value as true in the data, we're adding alert
to the payload. It's because of this:
The system executes your notification content app extension only when a remote notification’s payload contains the following information:
- The payload must include the mutable-content key with a value of 1.
- The payload must include an alert dictionary with title, subtitle, or body information.
Detailed info can be found at https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications
It only affects iOS and does not affect Android or other pusher types.
sygnal/apnspushkin.py
Outdated
@@ -299,6 +299,13 @@ def _get_payload_event_id_only(self, n): | |||
if n.counts.missed_calls is not None: | |||
payload["missed_calls"] = n.counts.missed_calls | |||
|
|||
payload["aps"] = {"mutable-content": 1} | |||
if ( | |||
n.devices[0].data["fallback_content"] is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we only look at the first device
? Shouldn't this be looking at the device we are preparing the payload for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Updated.
sygnal/apnspushkin.py
Outdated
payload["aps"] = {"mutable-content": 1} | ||
if ( | ||
n.devices[0].data["fallback_content"] is not None | ||
and n.devices[0].data["fallback_content"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need to be specced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about that, the fallback_content
will be an additional field in data
property of https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set. Plus homeserver just passes this data
according to this:
A dictionary of additional pusher-specific data. For 'http' pushers, this is the data dictionary passed in at pusher creation minus the url key.
Detailed info can be found here: https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, for client implementations to know what to set, and for pushgateway implementations to know how to interpret it, it has to be specced, otherwise this becomes secret knowledge which will only work with riot-ios and sygnal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per matrix-org/matrix-spec-proposals#2631 (comment): no, it doesn't need to be in the spec. Sorry!
That said, I do think it would be useful if we documented somewhere within the sygnal project what parameters the apnspushkin
supports in its data
dict and what they do. Perhaps you could add these details under https://github.com/matrix-org/sygnal#app-types ?
sygnal/apnspushkin.py
Outdated
payload["aps"] = {"mutable-content": 1} | ||
if ( | ||
n.devices[0].data["fallback_content"] is not None | ||
and n.devices[0].data["fallback_content"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, for client implementations to know what to set, and for pushgateway implementations to know how to interpret it, it has to be specced, otherwise this becomes secret knowledge which will only work with riot-ios and sygnal.
default_payload
in Push Payloads
Decided to update this with a more general solution. Offering use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things to fix here.
Please can you add some documentation for each of the two pushkins, which documents the structure of the data
field they expect?
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Sure, is it ok to add these in Pushkin classes, like: Line 66 in d63e70f
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks good now. I look forward to seeing the docs!
thanks, README updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of suggestions
README.rst
Outdated
When calling https://matrix.org/docs/spec/client_server/r0.5.0#post-matrix-client-r0-pushers-set, clients | ||
can provide a ``default_payload`` data dictionary in ``PusherData``, which will be passed to Sygnal. | ||
This will be used by Sygnal to have a default data dictionary in the push payload, for both APNS and | ||
GCM pushers, if provided. Upon the default payload dictionary, Sygnal will make incremental changes. | ||
This is useful for clients to decide default push payload content. For instance, iOS clients will have | ||
freedom to use silent/mutable notifications and be able to set some default alert/sound/badge fields. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer to start a list here.
The following parameters can be specified in the `data` dictionary which is given when configuring the pusher
via `POST /_matrix/client/r0/pushers/set <https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set>`_ :
* ``default_payload``: a dictionary which defines the basic payload to be sent to the notification service.
Sygnal will merge information specific to the push event into this dictionary. If unset, the empty dictionary is used.
This can be useful for clients to specify default push payload content.... etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, updated
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
README.rst
Outdated
======= | ||
|
||
The following parameters can be specified in the `data` dictionary which is given when configuring the pusher | ||
via [POST /_matrix/client/r0/pushers/set](<https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set>) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is RST, so this format doesn't work. I think I got it right in my suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry yes, you're right. I was bitten by my previewer. Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thank you for bearing with it!
Great, thanks for your valuable comments. |
I got this error when I send it empty, what shoud be sent inside ?: Jun 28 22:08:54 ip-172-31-11-241 python3[4208]: 2020-06-28 22:08:54,462 [4208] ERROR sygnal.http [40efe488-af22-41ee-8fc2-da59be7238b7] Exception whilst dispatching notification. "data": { |
Nothing actually. I've tested your data dictionary and it was fine in my Sygnal. I'm not sure what's the root cause but you may remove |
it's working without it, but I don't receive any notification on ios side. |
Add
fallback_content
case handling from push data to includealert
andmutable-content
fields in theaps
dictionary.Part of element-hq/element-ios#3325