Why did you suspect it was a syntax error?
In looking at the App Manifest in Chrome DevTools, I see a message: property 'icons' ignored, type array expected.
I think the problem is you’re passing an associative array to the icons and not an indexed array of associative arrays. You’re missing a nesting level of arrays. So this should do it:
add_filter('web_app_manifest', function ($manifest) {
$manifest['shortcuts'] = array(
array(
'name' => 'Sunglasses',
'short_name' => 'Sunglasses',
'Description' => 'Sunglasses',
'url' => 'https://www.demosite.com/sunglasses/',
'icons' => array(
array(
'src' => 'https://www.demosite.com/wp-content/uploads/2022/08/Sunglasses-Gradient-Round-96.png',
'size' => '96×96',
),
),
),
array(
'name' => 'Eyeglasses',
'short_name' => 'Eyeglasses',
'Description' => 'Eyeglasses',
'url' => 'https://www.demosite.com/eyeglasses/',
'icons' => array(
array(
'src' => 'https://www.demosite.com/wp-content/uploads/2022/08/Eyeglasses-Gradient-Round-96.png',
'size' => '96×96',
),
),
),
array(
'name' => 'Contact Lenses',
'short_name' => 'Contacts',
'Description' => 'Contact Lenses',
'url' => 'https://www.demosite.com/contact-lenses/',
'icons' => array(
array(
'src' => 'https://www.demosite.com/wp-content/uploads/2022/08/Contact-Lens-Gradient-Round-96.png',
'size' => '96×96',
),
),
),
);
return $manifest;
});