I have a PWA that is used in a controlled environment (meaning it's only used by a few people, so I have access to all the devices, so I have much room for workarounds). The PWA can be installed, that's how it's used on Android devices. I have a service-worker that caches the files. The PWA receives push-notifications through Firebase Messaging.
I send this to get a push-notification:
notification:
{
title:"Video call!",
body:"Videó call from:"+m,
click_action: "https://examplesite.app/?x="+m,
sound: "default",
vibrate: [200, 100, 200, 100, 200, 100, 200]
}
My problem is I want the PWA to play a longer ringtone in the background when a push-notification comes in, just like when a normal call comes in on the phone. How can I achieve this? I have read that browsers do not support such things, however I am trying to look for any kind of workaround. If the service-worker could play a ringtone whenever there's an incoming push-notification, it would be great. I only need to achieve this on mobile devices, however at this point I can't rework the PWA into an Android application if that could make a difference. I could write a tiny Android application that's only there to listen for such notifications and play music, if it's even possible.
So is there any way I can make the PWA play a ringtone when there is a push-notification coming in?