I am trying to send critical alerts from PHP backend to my iOS app via FCM. The problem is, that the notifications are not treated as critical alerts and won´t bypass "Do Not Disturb"-mode.
Payload sent from Backend to FCM (Example)
{
"to": "<fcm token>",
"data": {"property-1": "value-1"},
"priority": "high",
"notification": {
"title": "Hello World!",
"body": "Lorem Ipsum ...",
"badge": 1
"sound": {
"critical": 1,
"name": "default",
"volume": 1.0
},
"color": "#ffffff"
},"time_to_live": 300,
"content_available": true
}
According to the Apple documentation this format should be valid.
In settings critical alerts are enabled.
The only suspicious thing I´ve found so far, is that the userInfo
variable holding the information of the push notification holds sound
as JSON-string instead of a serialized object.
Printing description of userInfo:
▿ 4 elements
▿ 0 : 2 elements
▿ key : AnyHashable("gcm.message_id")
- value : "gcm.message_id"
- value : <message-id>
▿ 1 : 2 elements
▿ key : AnyHashable("google.c.a.e")
- value : "google.c.a.e"
- value : 1
▿ 2 : 2 elements
▿ key : AnyHashable("aps")
- value : "aps"
▿ value : 4 elements
▿ 0 : 2 elements
- key : content-available
- value : 1
▿ 1 : 2 elements
- key : alert
▿ value : 2 elements
▿ 0 : 2 elements
- key : title
- value : Hello World!
▿ 1 : 2 elements
- key : body
- value : Lorem Ipsum ...
▿ 2 : 2 elements
- key : badge
- value : 1
▿ 3 : 2 elements
- key : sound
- value : {"volume":1.0,"critical":1,"name":"default"}
▿ 3 : 2 elements
▿ key : AnyHashable("message")
- value : "message"
- value : {"data":...}
Is this a bug in iOS or APNS?
{"volume":1.0,"critical":1,"name":"default"}
Any ideas how to get this working?