HomeiOS Developmentpython - Easy methods to embrace additional knowledge fields in FCM payload...

python – Easy methods to embrace additional knowledge fields in FCM payload (iOS)?


I need to ship a payload that specifies a sound to play upon the notification on the gadget, in order that the payload appears like this:

{
    "to":"myToken",
    "notification":{
        "title":"new message",
        "physique":"Hiya World!",
        "sound":"specifiedSound.caf",
    }
}

Nevertheless, in my python script, once I tried so as to add an additional discipline to the notification it says that sound is an surprising argument:

message = messaging.Message(
        notification = messaging.Notification(
            title = "Title",
            physique = "Physique",
            sound = "specifiedSound.caf"                <-- surprising argument
        ),
        token = "myToken"
    )

    # Ship message
    response = messaging.ship(message)
    print("Efficiently despatched message:", response)
Traceback (most up-to-date name final):
  File "/Customers/joelin/Paperwork/GitHub/taiwanEEW-Server/eewPush.py", line 53, in <module>
    send_data("3", 3)
  File "/Customers/joelin/Paperwork/GitHub/taiwanEEW-Server/eewPush.py", line 36, in send_data
    notification = messaging.Notification(
TypeError: Notification.__init__() acquired an surprising key phrase argument 'sound'

I additionally tried this however nonetheless does not work

notification = messaging.Notification(
            title = "Title",
            physique = "Physique"
        ),
        knowledge = {
            "sound":"soundtest"
        }
...
    return _get_messaging_service(app).ship(message, dry_run)
  File "/Library/Frameworks/Python.framework/Variations/3.10/lib/python3.10/site-packages/firebase_admin/messaging.py", line 355, in ship
    elevate self._handle_fcm_error(error)
firebase_admin.exceptions.InvalidArgumentError: Request comprises an invalid argument.

I’ve tried my finest looking for the reply, sorry if this can be a duplicate query, thanks a lot!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments