Can apple push notifications send more parameters than alert and sound?

后端 未结 4 1221
无人共我
无人共我 2020-12-13 05:20

I have several pieces of metadata that I need to associate with a push notification.

For example user no, message id.

Can I send more parameters than what ap

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 05:32

    You are not allowed to put custom tags inside aps tag. Here's what documentations says about it:

    Providers can specify custom payload values outside the Apple-reserved aps namespace. Custom values must use the JSON structured and primitive types: dictionary (object), array, string, number, and Boolean.
    

    So in your case you should do something like:

    {
        "aps": {
            "alert": "Hello Push",
            "sound": "default"
        },
        "People": {
            "Address": "Your address here",
            "Name": "Your Name here",
            "Number": "XXXXXXXXXX"
        }
    }
    

    Therefore you can read your custom payload with looking for it's key in main JSON, rather than in "aps":

提交回复
热议问题