When updating a Live Activity via OneSignal’s API, the notification sound plays even if sound: "nil" or ios_sound: "nil" is set in the request payload. Additionally, if the device is in silent mode, the phone still vibrates, despite attempts to disable sound and vibration. This issue prevents silent Live Activity updates, which should not trigger any sound or vibration.
Send a Live Activity update request via OneSignal’s API with the following payload:
{
"event": "update",
"include_subscription_ids": ["{{subs_id}}"],
"event_updates": { "data": { "progress": 50 } },
"event_attributes": {
"data": { "title": "Test Title", "description": "Test Description" }
},
"activity_id": "{{activity_id}}",
"name": "Test Live Activity",
"contents": { "en": "Test Message" },
"headings": { "en": "Test Heading" },
"sound": "nil",
"ios_sound": "nil",
"priority": 5
}
Observe that the device still plays a sound when the Live Activity update arrives.
Put the iPhone into silent mode and send another update request.
Observe that the device vibrates even though sound is disabled.
I expected the Live Activity update to be completely silent—no sound, no vibration—when sound: "nil" or ios_sound: "nil" is set. The behavior should be consistent with normal OneSignal notifications, where setting ios_sound: "nil" successfully suppresses sound.
5.2.9
iOS
I also set content_available
to true
for silent live activity push and removed the contents headings fields.
I get 400 from the request response
{
"event": "update",
"content_available": true, <--- this field
"include_subscription_ids": [
"{{subs_id}}"
],
"event_updates": {
"data": {
"progress": 40
}
},
"event_attributes": {
"data": {
"title": "Test",
"description": "Test description",
}
},
"activity_id": "{{activity_id}}",
"name": "OneSignal Notification Name"
}
{
"errors": null,
"field_errors": {
"message": [
"Notifications must have Any/English language content"
],
"contents": [
"contents is required for live activity start notifications"
],
"headings": [
"headings is required for live activity start notifications"
]
}
}
I found out that when I send an update request, OneSignal always creates a new Live Activity instead of updating the existing one. So the update request works exactly like a start request. It took me some time to understand this, so I wanted to share it here.
https://api.onesignal.com/apps/{{onesignal_app_id}}/activities/activity/{{activity_type}}
{
"event": "start",
"include_subscription_ids": [
"{{subs_id}}"
],
"event_updates": {
"data": {
"progress": 10,
"title": "Leila is on the way!",
"description": "Arriving between 09:30-10:00",
}
},
"event_attributes": {
"data": {}
},
"activity_id": "{{activity_id}}",
"name": "Live activity Start",
"contents": {
"en": "English Message"
},
"headings": {
"en": "English Message"
},
"priority": 10
}
Remove all fields such as contents, headings, sound, ios_sound, content_available,
etc., from the payload—keep only event, name, event_updates, and priority.
https://api.onesignal.com/apps/{{onesignal_app_id}}/live_activities/{{activity_id}}/notifications
{
"event": "update",
"include_subscription_ids": [
"{{subs_id}}"
],
"event_updates": {
"data": {
"progress": 80,
"title": "Leila is on the way!",
"description": "Arriving between 09:30-10:00"
}
},
"activity_id": "{{activity_id}}",
"name": "Live activity Update",
"priority": 10
}
https://api.onesignal.com/apps/{{onesignal_app_id}}/live_activities/{{activity_id}}/notifications
{
"event": "end",
"include_subscription_ids": [
"{{subs_id}}"
],
"event_updates": {
"data": {}
},
"event_attributes": {
"data": {}
},
"activity_id": "{{activity_id}}",
"name": "Live activity End",
"priority": 10,
"stale_date": 1695760785,
"dismissal_date": 1703505600
}