Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion functions/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,25 @@ module.exports = {
'progress_indeterminate',
'live_update',
'critical_text',
'progress_segments',
'progress_points',
'progress_start_icon',
'progress_end_icon',
'progress_tracker_icon',
'progress_start_color',
'progress_end_color',
'progress_tracker_color',
Comment on lines +116 to +123

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

];

androidNotificationKeys.forEach((key) => {
if (Object.hasOwn(req.body.data, key)) {
payload.data[key] = String(req.body.data[key]);
// 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]);
}
Comment on lines +128 to +134

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

}
});
}
Expand Down