fix(pwa): route sw.js and manifest.json dynamically with Service-Worker-Allowed header and exact screenshot dimensions
This commit is contained in:
parent
0135e6482a
commit
c1a532ce95
|
|
@ -1569,6 +1569,8 @@ $routes->get('app/nursing/(:any)', 'Api\v1\NursingApi::pwaIndex');
|
|||
$routes->get('app/doctor', 'Api\v1\DoctorApi::pwaIndex');
|
||||
$routes->get('app/doctor/(:any)', 'Api\v1\DoctorApi::pwaIndex');
|
||||
$routes->get('app/queue', 'Api\v1\DoctorApi::queueIndex');
|
||||
$routes->get('app/queue/sw.js', 'Api\v1\DoctorApi::queueSw');
|
||||
$routes->get('app/queue/manifest.json', 'Api\v1\DoctorApi::queueManifest');
|
||||
$routes->get('app/queue/(:any)', 'Api\v1\DoctorApi::queueIndex');
|
||||
|
||||
// Dedicated RESTful JSON API v1 Group for React PWAs & Mobile Apps
|
||||
|
|
|
|||
|
|
@ -676,6 +676,33 @@ class DoctorApi extends BaseController
|
|||
return redirect()->to(base_url('app'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Serves the Service Worker script for /app/queue
|
||||
*/
|
||||
public function queueSw()
|
||||
{
|
||||
$swPath = FCPATH . 'App/Queue/sw.js';
|
||||
if (file_exists($swPath)) {
|
||||
return $this->response->setHeader('Content-Type', 'application/javascript')
|
||||
->setHeader('Service-Worker-Allowed', '/')
|
||||
->setBody(file_get_contents($swPath));
|
||||
}
|
||||
return $this->response->setStatusCode(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serves manifest.json for /app/queue
|
||||
*/
|
||||
public function queueManifest()
|
||||
{
|
||||
$manifestPath = FCPATH . 'App/Queue/manifest.json';
|
||||
if (file_exists($manifestPath)) {
|
||||
return $this->response->setHeader('Content-Type', 'application/json')
|
||||
->setBody(file_get_contents($manifestPath));
|
||||
}
|
||||
return $this->response->setStatusCode(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET api/v1/opd/queue/live
|
||||
* Returns real-time OPD Tokens & Hospital Showcase Ads for TV Queue Display
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>OPD Token Tracker & Queue Display - HMS Mobile</title>
|
||||
<link rel="manifest" href="/App/Queue/manifest.json">
|
||||
<link rel="manifest" href="/app/queue/manifest.json">
|
||||
<meta name="theme-color" content="#0f172a">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
|
|
@ -438,7 +438,7 @@
|
|||
// Register PWA Service Worker
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function() {
|
||||
navigator.serviceWorker.register('/App/Queue/sw.js')
|
||||
navigator.serviceWorker.register('/app/queue/sw.js', { scope: '/app/queue/' })
|
||||
.then(function(reg) { console.log('Queue PWA Service Worker Registered', reg); })
|
||||
.catch(function(err) { console.log('Service Worker Registration Failed', err); });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
"theme_color": "#0f172a",
|
||||
"display": "standalone",
|
||||
"display_override": ["standalone", "minimal-ui"],
|
||||
"orientation": "landscape",
|
||||
"categories": ["medical", "health", "utilities"],
|
||||
"prefer_related_applications": false,
|
||||
"icons": [
|
||||
|
|
@ -50,7 +51,7 @@
|
|||
"screenshots": [
|
||||
{
|
||||
"src": "/assets/img/slides-1.jpg",
|
||||
"sizes": "1280x720",
|
||||
"sizes": "1024x683",
|
||||
"type": "image/jpeg",
|
||||
"form_factor": "wide",
|
||||
"label": "OPD Token Tracker & Hospital Showcase TV Display"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user