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

Allow to configure if pushkey should be converted to hex before sending to APNs #344

Merged
merged 6 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sygnal.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ apps:
# #
# # The default is 'production'. Uncomment to use the sandbox instance.
# #platform: sandbox
# #
# # Specifies whether to convert the device push token from base 64 to hex.
# # Defaults to True, set this to False if your client library provides a
# # push token in hex format.
# #convert_device_token_to_hex: false

# This is an example GCM/FCM push configuration.
#
Expand Down
7 changes: 6 additions & 1 deletion sygnal/apnspushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ async def _dispatch_request(
log.info(f"Sending as APNs-ID {notif_id}")
span.set_tag("apns_id", notif_id)

device_token = base64.b64decode(device.pushkey).hex()
# Some client libraries will provide the push token in hex format already. Avoid
# attempting to convert from base 64 to hex.
if self.get_config("convert_device_token_to_hex", bool, True):
device_token = base64.b64decode(device.pushkey).hex()
else:
device_token = device.pushkey

request = NotificationRequest(
device_token=device_token,
Expand Down
Loading