Google Chrome: DOMException: Registration failed - manifest empty or missing
Solution 1
Because I didn't find an answer anywhere out there in the WWW, but managed to get it working after some time I want to provide my solution/answer for other users, who probably have the same problem:
In the file where I inlcuded the Pushpad files I wrote some PHP-Code before the <head>
-Tag to include some files, e.g. for database connection. After I moved the PHP-Code below the <head>
-Tag everything worked fine.
Solution 2
For me it was a redirect. The manifest.json
must return a 200 status code (must be directly available from the server), without any redirects.
You can check the response via
wget --max-redirect=0 https://example.com/manifest.json
or
curl https://example.com/manifest.json
Solution 3
I faced same issue,added manifest file right after head tag . which worked for me.Cheers!
Solution 4
This may be an issue with your Service Worker scope. I ran into a similar problem when I rearranged my files/directories. Make sure your sw.js is on the same level as your manifest.json, otherwise the service worker won't be able to find your manifest. Try putting them both in the root of your directory. Optionally, you can specify the scope
of your service worker by adding it to serviceWorker.register()
:
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw-test/sw.js', {scope: '/sw-test/'})
.then(function(reg) {
// registration worked
console.log('Registration succeeded. Scope is ' + reg.scope);
}).catch(function(error) {
// registration failed
console.log('Registration failed with ' + error);
});
}
Read more here: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
Related videos on Youtube
Fabian H.
Programming Skills: Java (Android) Visual Basic C++ BAAN LN/ERP SQL PHP Javascript (CSS) (HTML) Media Design Skills: Video Editing (Premiere, Camtasia) Filming/Capturing (with Canon EOS 600D, Fraps) Audio Editing (Audacity, Fruity Loops) Picture Editing (Photoshop, Lightroom) Animation (After Effects, Cinema4D) Hobbys: Coding <3 Learning new programming languages and facing new challenging projects event technichan for sound and light (Musicals, Theaters, ...)
Updated on June 04, 2022Comments
-
Fabian H. almost 2 years
I am trying to implement Push Notifications on my website (using Pushpad). Therefore I created a "manifest.json" with following content:
{ "gcm_sender_id": "my_gcm_sender_id", "gcm_user_visible_only": true }
of course I created a valid GCM-Account and have a sender id
I put the manifest.json into my root directory and I also added this line to my index.php:
<link rel="manifest" href="/manifest.json">
Using Firefox everything works fine and I can send and receive push notifications (so I think the manifest-include works fine), but Chrome won't work...
The console shows following error:
Uncaught (in promise) DOMException: Registration failed - manifest empty or missing
I searched Google for a long time and tried everything I found, but nothing works.
What I tried:
- created the manifest.json with "Editor" and saved it as type All Types (so no hidden .txt-file) and also with UTF-8-Encoding.
- restarted Chrome
- cleared Chrome's cache, history, etc.
I really hope somebody can help me.
-
Marco Castelluccio almost 8 yearsFirefox works because it doesn't require a manifest in order to enable push. Can you try loading the manifest directly in your browser to see if you can actually access it?
-
collimarco almost 8 yearsI confirm that Firefox doesn't look for a manifest file, so that's the reason why it works. Have you tried typing in the address bar the url
https://yourwebsite.com/manifest.json
and see if it's returned correctly? Can you provide a link to your website? -
collimarco almost 8 years@FabianH. Another guess: are you sure that you have the
/
beforemanifest.json
? Try opening the network tab of the Chrome developers tools and see if the request ofmanifest.json
is completed successfully