Set custom fields in aps alert dictionary
See original GitHub issueHello, thanks for creating Pushy. I have a VOIP app which requires data payload with its alert dictionary in this format:
"alert": { "uuid": "xxxx", "incoming_caller_id": "yyy", "incoming_caller_name": "zzz", }
How can I add these custom keys (uuid, incoming_caller_id, incoming_caller_name
) to the alert
dictionary? I have gone through the docs for ApnsPayloadBuilder
, and I could see methods to set standard fields (e.g. setAlertBody
) and I could see a method called setLocalizedAlertMessage
.
I thought of using setLocalizedAlertMessage("uuid", "xxxx")
- however looking into its implementation, it seemed that it will create two separate entries in the alert
dictionary (e.g. {"loc-key" : "uuid", "loc-args" : ["xxxx"]}
), so I’m unsure it will work. Kindly help.
P.S. The format of the alert
dictionary is mandated by a Flutter package (Flutter VOIP IOS Kit) that I’m using at my Frontend.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
The
payload
of anApnsPushNotification
is just aString
. You can pass any value—legal or not—as the payload.The closest thing we have is
ApnsPayloadBuilder#addCustomProperty(String, Object)
, but it sounds like that’s not what you need.It sounds like what Flutter is asking you to do goes against what Apple’s docs specify. The docs say (emphasis added):
…so adding new keys to the
alert
dictionary inside ofaps
would violate that guidance, and I don’t think that’s something we want to add to Pushy.That said, remember that payloads are just JSON objects, and you can construct them however you’d like! You could use the JSON library of your choice to encode arbitrary objects, or even just use
String#format
if you want.Because there’s a viable workaround, because this doesn’t appear to be a widespread need, and because it would go against the official docs, I’m going to close this as “won’t fix.”