Support progress styling keys on Android - #317
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Expands supported Android notification payload keys and improves how FCM data payload values are serialized to meet FCM’s “strings only” requirement.
Changes:
- Added additional
progress_*keys toandroidNotificationKeys. - Updated payload construction to JSON-stringify object values while stringifying primitives.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // If the value is an object, stringify it. Convert everything else to a string. | ||
| // This is because FCM data payloads must be strings. | ||
| if (typeof req.body.data[key] === 'object') { | ||
| payload.data[key] = JSON.stringify(req.body.data[key]); | ||
| } else { | ||
| payload.data[key] = String(req.body.data[key]); | ||
| } |
There was a problem hiding this comment.
I think the preferred approach would be option a, since option b would just silently fail with no means to debug.
I'll update handlers.js to include some error handling and returning it to Home Assistant
| 'progress_segments', | ||
| 'progress_points', | ||
| 'progress_start_icon', | ||
| 'progress_end_icon', | ||
| 'progress_tracker_icon', | ||
| 'progress_start_color', | ||
| 'progress_end_color', | ||
| 'progress_tracker_color', |
There was a problem hiding this comment.
I would like this to be verify with @bgoncal to see if iOS can use them like this or if it's specific to Android.
There was a problem hiding this comment.
Are you worried about the data structure or the keys themselves?
iOS will have to map them in the file (currently called) legacy.js anyways so, as long it comes from the user's yaml payload iOS can deal with it.
If the question is regard if iOS can use these keys to create the UI, yes it can, in iOS the live activity is kinda white board, we can draw anything (non-animated) in there, but I havent reviewed the way this is being designed for the user to use, I mean.. is there a more clever way? But then it's better to read the docs to see if it is intuitive enough for the user.
There was a problem hiding this comment.
Then let's discuss in home-assistant/companion.home-assistant#1297 the idea is to validate the fields also for you if you can use them later.
This PR contains two parts: