I'm in the process of creating my first PWA and testing around a lot. This is a driver app for my boss. Now I'm at a point where I can't really get any further. If the app is running in the background, the location and current speed should continue to be sent. Location and speed are not a problem and the data is also sent to the server.
The big problem is the service worker. I have already read many posts on the Internet that it is possible to continue sending the data with a service worker, even if the app is running in the background. Unfortunately, this doesn't last long. After about 1 minute it stops sending this data and I don't know why. Perhaps someone from you can give me a tip as to why this is the case. My service worker isn't that big either
Javascript:
document.addEventListener ("DOMContentLoaded", function () {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register ('/ js / sw.js', {scope: '/ js /'}). then (function (reg) {
console.log ('Registration Successful');
}). catch (function (error) {
console.log ('Registration failed with' + error);
});
};
});
The function SaveSpeerd2F () is in the file sw.js and contains the query of the position and the current speed and then sends this via Jquery Ajax to the server with a time interval of 5 seconds. As already said, it stops sending data after about 1 minute and I don't really know why. Mehr zu diesem Ausgangstext Für weitere Übersetzungsinformationen ist ein Ausgangstext erforderlich Feedback geben Seitenleisten