Laravel Application with PWA

Laravel Application with PWA

Install the following package

composer require ladumor/laravel-pwa

Adding service on app.php

Ladumor\LaravelPwa\PWAServiceProvider::class,

'LaravelPwa' => \Ladumor\LaravelPwa\LaravelPwa::class,

To Publish configuration

php artisan laravel-pwa:publish

On main file app.blade.php add the manifest

<meta name="theme-color" content="#6777ef"/>
<link rel="apple-touch-icon" href="{{ asset('logo.png') }}">
<link rel="manifest" href="{{ asset('/manifest.json') }}">

On Root file add the following script

<script src="{{ asset('/sw.js') }}"></script>
<script>
    if (!navigator.serviceWorker.controller) {
        navigator.serviceWorker.register("/sw.js").then(function (reg) {
            console.log("Service worker has been registered for scope: " + reg.scope);
        });
    }
</script>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s