Uncaught ReferenceError: importScripts is not defined on push-worker.js

Hello after setup web notifications to my https site, y downloaded the sdk ( snippet.js and push-worker.js). I added script from snipped and under root y place the push-worker.js. following all steps.  

When i reloaded the site and i got this javascript error :  Uncaught ReferenceError: importScripts is not defined on push-worker.js line 2.  also Opt-in confirmation is not displayed, nothing happens!!.

It seems the worker is register i on Chrome and also i have last Firefox version both of thems accepts services worker notifications.

 

Any clue to solve this?

Didn't find what you were looking for?

New post

Comments

2 comments

  • Gaspar,

    The most common cause for the error is explicitly referencing the push-worker.js by adding it in a script tag. If this is what you have done, you can remove the script tag. The snippet that you added to your page will load the push-worker.js for you.

    Please let us know if this solves your problem.

    Thank you,
     
    Eric L.
    Technical Support Engineer
    Airship | Portland
    0
  • Hello Eric, thanks for your answer. Regarding your message I didn't add any extra tag or made changes on original files/script downloaded from setup.

    i copy/paste the snippet into mi home page (header sections)

    I move the push.worker.js to root /  and made accesible

    If you see the push-worker.js has this sentences:

    importScripts('https://*****your ua-sdk  js file***');
    uaSetup.worker(self, {
    defaultIcon: 'https://mysite/pub/media/logo/logo.png',
    defaultTitle: 'mysitename',
    defaultActionURL: 'https://mysitename.com',
    appKey: '*********************+',
    token: '****************************',
    vapidPublicKey: '***************************='
    })

    importScripts(' ');  is not allowed has an error, so i think the service worker is not well initialized with the params.

    best regards

    0

Please sign in to leave a comment.