Closed iAmWillShepherd closed 2 years ago
@iAmWillShepherd Looks like the request to localhost:8080/OneSignalSDKWorker.js?appId=6620ca78-6da6-4346-bd79-5f893b33459f?sdkVersion=151510
is not giving back a Content-Type
HTTP header to the browser based on your Request
code block above. It should be something like Content-Type: application/x-javascript;charset=utf-8
.
If you do the same kind of GET request noted above on these URL does the HTTP headers in the response change?
localhost:8080/OneSignalSDKWorker.js
Content-Type
localhost:8080/OneSignalSDKWorker.js?appId=6620ca78-6da6-4346-bd79-5f893b33459f&sdkVersion=151510
?
with &
to fix the URL query string, wondering if it caused an issue with your local serverGET /OneSignalSDKWorker.js HTTP/1.1
Content-Type: application/x-javascript;charset=utf-8
Host: localhost:8080
Connection: close
User-Agent: Paw/3.3.2 (Macintosh; OS X/12.0.1) GCDHTTPRequest
HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Security-Policy: default-src 'none'
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 160
Date: Mon, 13 Dec 2021 19:38:33 GMT
Connection: close
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /OneSignalSDKWorker.js</pre>
</body>
</html>
I received the same result sending a request to your second suggestion, localhost:8080/OneSignalSDKWorker.js?appId=6620ca78-6da6-4346-bd79-5f893b33459f&sdkVersion=151510
, so I also tried to do it in the browser and received the following in my console.
I've seen an error similar to this caused by not installing the service worker file in the public folder of the project. Could it be that I need to manually install the service worker? The getting started guide makes no mention of it, so I didn't do the typical song and dance I typically would to make that file available.
@iAmWillShepherd ah yes that is it, you do need to manually put the OneSignal service worker file (OneSignalSDKWorker.j
) in your public folder. We should update the docs to instruct developers to do that.
It might be possible in the future for this plugin to automatically include OneSignalSDKWorker.j
. Somethings to consider however before attempting to do this is:
Another option to help developer might be to offer a plugin for ways you can host, such as express
as you are running here.
I ran into this issue while attempting to integrate with the plugin a Vue2 project following the instructions on npm.
Note that the Service worker appears to be installed and OneSignal is initialized, but when I click Allow in the notification dropdown, nothing happens on the screen; however, there is an error emitted to the console.
Console output
Full log ☝🏾
I did a bit of digging and noticed this request is returning a webpage result. I'm not sure if it's relevant to the issue, but since it's sending a request to the web worker, I figured I'd share a bit more info on it.
Request
Response