jazzband / django-push-notifications

Send push notifications to mobile devices through GCM or APNS in Django.
MIT License
2.24k stars 609 forks source link

++Enable sending image in GCM notifications #624

Closed ashishnitinpatil closed 2 years ago

ashishnitinpatil commented 2 years ago

Existing behavior sends it under the data field which doesn't behave correctly with the native image notifications.

Fixes https://github.com/jazzband/django-push-notifications/issues/559

codecov[bot] commented 2 years ago

Codecov Report

Merging #624 (fc6ac92) into master (c5e712a) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #624   +/-   ##
=======================================
  Coverage   68.24%   68.24%           
=======================================
  Files          24       24           
  Lines        1099     1099           
  Branches      173      173           
=======================================
  Hits          750      750           
  Misses        312      312           
  Partials       37       37           
Impacted Files Coverage Δ
push_notifications/gcm.py 79.12% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c5e712a...fc6ac92. Read the comment docs.

LeeHanYeong commented 2 years ago

To deliver an image to the recipient in FCM's notifications payload, you must use the "image" key. I hope there is a quick release.

https://firebase.google.com/docs/cloud-messaging/android/send-image

alexislg2 commented 2 years ago

Thanks, it is so easy. Waiting for the release!

astrike30 commented 2 years ago

Can anyone confirm that this is working? I have tried passing image=url... and as extra={"image": url} but I cant seem to get either to work.

ashishnitinpatil commented 2 years ago

Yes @astrike30 I can confirm it works with extra={"image": url} where url is well-formed & publicly accessible. Sometimes, the FCM network fails showing the image for some random reasons, so make sure to test on multiple devices if one doesn't seem to work.