healthjoy / async-firebase

The lightweight asynchronous client that makes interaction with Firebase Cloud Messaging oversimplified.
MIT License
37 stars 14 forks source link

Remove reference clear for parent dict #47

Closed Narquadah closed 1 year ago

Narquadah commented 1 year ago

Describe the bug On iOS only the first message with custom_data get's the actual data, any subsequent notifications don't get any content in custom_data.

To Reproduce Steps to reproduce the behavior: This can be observed anytime a single apns object is used.

example 1:

ios = [ .... device tokens, ]

apns = client.build_apns_config(
  content_available=True,
  priority="5",
  custom_data={ 'hello': 'world' }
)
print(apns.payload.aps.custom_data) # => { 'hello': 'world' }
await client.push_multicast(ios, apns=apns)

print(apns.payload.aps.custom_data) # => {}

example 2:

apns = client.build_apns_config(
  content_available=True,
  priority="5",
  custom_data={ 'hello': 'world' }
)

print(apns.payload.aps.custom_data) # => { 'hello': 'world' }
for device in ios:
  #  if first iteration
  print(apns.payload.aps.custom_data) # => { 'hello': 'world' }
  # second iteration
  print(apns.payload.aps.custom_data) # => {}

  await client.push(device, apns=apns)
  # always
  print(apns.payload.aps.custom_data) # => {}

Expected behavior All devices receive the same data.

Additional context If line 21 in encoder.py is removed, it works.

aps.custom_data.clear()  # type: ignore

All tests are still running.