Giter Club home page Giter Club logo

Comments (10)

xtrinch avatar xtrinch commented on May 20, 2024

'kwargs' is not a keyword argument, so don't name it, just pass it as the last argument.

Also please be more specific as to how the payload gets 'messed up'.

from fcm-django.

monicaphalswal avatar monicaphalswal commented on May 20, 2024

I changed the code to:

kwargs = {
        'content_available': True
}
devices.send_message(
                title="Syncup", 
                body=".", 
                icon="appicon", 
                data={
                    "notification type" : 20
                },
                kwargs
           )

But now I am getting error:
SyntaxError: non-keyword arg after keyword arg

And for the missing 'body' part, the payload changes from
{"data":{"notification type":20},"notification":{"body":".","icon":"appicon","title":"Syncup"},"priority":"high","to":"cF3VXFqliZQ:APA91bG3xXHeuoIx2TMYXLcTXooqQyRPiKzfGL4l4h8Cfxpl3vFBVmYY2YuqV6odipSnET2LNv3q4th5qxstNmonf_w2MnUrP77TNWfLV4iDlmNc_gCQPoR_w6F4U-3hJkVAM3ujNKMY"}
to(title goes missing)
{"data":{"notification type":20},"notification":{"icon":"appicon"},"priority":"high","to":"cF3VXFqliZQ:APA91bG3xXHeuoIx2TMYXLcTXooqQyRPiKzfGL4l4h8Cfxpl3vFBVmYY2YuqV6odipSnET2LNv3q4th5qxstNmonf_w2MnUrP77TNWfLV4iDlmNc_gCQPoR_w6F4U-3hJkVAM3ujNKMY"}
(when I remove key "body" from above code).

from fcm-django.

xtrinch avatar xtrinch commented on May 20, 2024

http://stackoverflow.com/questions/1496346/passing-a-list-of-kwargs for passing kwargs

from fcm-django.

xtrinch avatar xtrinch commented on May 20, 2024

For the second part - pyfcm's github page is where that question would be answered best, because that part is handled in this file.

from fcm-django.

monicaphalswal avatar monicaphalswal commented on May 20, 2024

Thank you for the help. But, I'm still not able to send "mutable_content": True even in kwargs. I am getting notify_single_device() got an unexpected keyword argument 'mutable_content' error.

from fcm-django.

ipoogleduck avatar ipoogleduck commented on May 20, 2024

How did you end up fixing this? @monicaphalswal

from fcm-django.

merwok avatar merwok commented on May 20, 2024

The initial problem was that the function call had kwargs=extra_kwargs instead of the correct **kwargs (dictionary unpacking, to add more param=value parameters to the call).

The second problem is different (passing an unknown parameter to a function).

from fcm-django.

xtrinch avatar xtrinch commented on May 20, 2024

The question is for an obsolete version which used the legacy API, so this question is most likely not relevant anymore

from fcm-django.

ipoogleduck avatar ipoogleduck commented on May 20, 2024

Ah okay. I want to add channel_id from https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification to my notification payload so I was looking at this to see how it would be possible. I was thinking this would work but maybe I am on the wrong track?

fcm_send_topic_message(message_title=messageTitle,
                                   message_body=messageBody,
                                   condition=favoritesConditions, 
                                   data_message=notif_data,
                                   sound="Default",
                                   extra_kwargs={"android": "{\"notification\": {\"channel_id\": \"" + time_topic + "\"}}"})

from fcm-django.

xtrinch avatar xtrinch commented on May 20, 2024

@ipoogleduck

from firebase_admin.messaging import Message, Notification
topic = "A topic"
FCMDevice.objects.handle_subscription(True, topic)
FCMDevice.send_topic_message(Message(data={...}), "TOPIC NAME")

And the channel ID you would pass into the Message constructor under android_config, see
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#resource:-message

from fcm-django.

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.