Install Push Notifications Embed Code

For non-Shopify customers, there is a second embed code that needs to be installed to allow for full functionality. This does not mean that push notification subscriptions will not work on your website using the Justuno embed code, but the user experience will increase tremendously adding this code in as well! 

Step 1: Copy the code below

self.addEventListener('push', function (event) {

console.log('Push message!', event.data.text());

const payload = JSON.parse(event.data.text());

event.waitUntil(

self.registration.showNotification(payload.title, {

body: payload.body,

requireInteraction: payload.requireInteraction,

icon: payload.icon,

image: payload.image,

data: {

link: payload.link

}

}));

});

self.addEventListener('notificationclick', function (event) {

console.log('Notification click: tag', event.notification.tag);

event.notification.close();

if (event.notification.data.link) event.waitUntil(clients.openWindow(event.notification.data.link));

});

Step 2: Head to your website's back end. Below is an outline of how to connect and upload a file to your FTP

Step3: In this guide we will be using FileZilla. If you do not have an FTP Client please download the application. 

Step 4: If you have not created an account open the application and create one using the following instructions

  1. Head to My Account>Shared Hostin>Your Domain> Upload Website
  2. Enter in a Host: Your Server
  3. Enter in a User Name: your user name
  4. Enter in a Password
  5. Hit Quick Connect

Step 5: You are now connected to your Shared Hosting FTP server! In the upper tab you will see the info of your FTP connection. The left tab, called "Local Site", are the files on your own computer. The right tab, "Remote Site", is the most important one for this guide. In the tab Remote site you can find all Folders/Files that are present on your server space.

Step 6: Add in the code from above which can be saved in a document and drag it over to the Remote Site section

Step 7: Create a file called apps and then a subfolder called justuno. The file must route like this: https://www.yourdomain.com/apps/justuno/service-worker.js

Step 8: End the session by hitting disconnect and the Justuno Push notification file will be loaded on the website!