Unable to get Instance ID token
After allowing notification permission, I wasn't able to see Instance Token ID on Chrome 54.0.2840.59 (64-bit) version Screenshot: http://prnt.sc/cwkozz
If the IID token generation fails, it should be logged in the console, are you seeing any error message there?
I have tried on windows Chrome and it is giving error: browserErrorMessage : "Failed to register a ServiceWorker: ServiceWorker script evaluation failed" code : "messaging/failed-serviceworker-registration" message : "Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: ServiceWorker script evaluation failed (messaging/failed-serviceworker-registration)." stack : (...) get stack :
but on MAC OS Chrome , it was just saying "loading..." No error was available in the console. The test has been done Over https connections. Firefox is working on both Windows and MacOS platform. Only I am getting the problem with Chrome.
I think I'm missing something... http://www.solidarityfarm.tk/quickstart-js-master/messaging/index.html
This below is the only error I'm getting with Firefox 49.0.2 : An error occurred while retrieving token. Object { code: "messaging/unsupported-browser", message: "Messaging: This browser doesn't sup…", name: "FirebaseError", stack: "", 1 more
With above URL http://www.solidarityfarm.tk/quickstart-js-master/messaging/index.html I am getting "Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)." error in console.
Thank you for trying it inautus :) I appreciate that. Should I ask my hosting service to put my URL in an https:// in order for this messaging to work? Or is there another way to make it work?
i have eror too , like @inautus error: browserErrorMessage : "Failed to register a ServiceWorker: ServiceWorker script evaluation failed" code : "messaging/failed-serviceworker-registration" message : "Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: ServiceWorker script evaluation failed (messaging/failed-serviceworker-registration)
runing in localhost/firebase/quickstart/messaging anyone can hlep ?
The "script evaluation failed" normally means there was a problem with the javascript in the service worker file.
Does it link to a line number? Also are you starting the server in the messaging folder?
Matt
On Mon, 31 Oct 2016, 23:53 alfat osk, [email protected] wrote:
i have eror too , like @inautus https://github.com/inautus error: browserErrorMessage : "Failed to register a ServiceWorker: ServiceWorker script evaluation failed" code : "messaging/failed-serviceworker-registration" message : "Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: ServiceWorker script evaluation failed (messaging/failed-serviceworker-registration)
runing in localhost/firebase/quickstart/messaging anyone can hlep ?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-js/issues/69#issuecomment-257500829, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIh8P1KH5mK1m8eOJgPu3qpVv7SNoIbks5q5uH9gaJpZM4Kb1bu .
yess i got it , the problem is , script read server worker in http://localhost/firebase-messaging-sw.js , not in my app folder http://localhost/firebase/quickstart/messaging , so i must add file firebase-messaging-sw.js in root of folder localhost (/var/ww/html) , i dont know but its work
thank for answer mr @gauntface
but how to fx this ,to read firrebase-messaging-sw.js in my app directory?
The 'firebase-messaging-sw.js' file needs to be at the root of your project.
If you can't do that you can use the useServiceWorker(registration) method which would look something like this:
navigator.serviceworker.register('/app/path/example/sw.js')
.then((registration) => {
const messaging = firebase.messaging();
messaging.useServiceWorker(registration);
return messaging.getToken();
})
.then((token) => {
....
});
I am getting the similar error as following:
An error occurred while retrieving token. V {code: "messaging/failed-serviceworker-registration", message: "Messaging: We are unable to register the default s…t. (messaging/failed-serviceworker-registration).", browserErrorMessage: "Failed to register a ServiceWorker: A bad HTTP res…code (404) was received when fetching the script.", stack: "FirebaseError: Messaging: We are unable to registe….gstatic.com/firebasejs/3.5.1/firebase.js:537:225"}
And It is working fine and generating token on the chrome's localhost server but not working on my hosting server. Please Help! on issue.
I got same problem with all browser, When I am trying with my hosting server.
+1
I have the same problem. Analysing the code I saw the worker is registered as '/firebase-messaging-sw.js', so, putting 'firebase-messaging-sw.js' on website root, it works correctly. It seems to me it's a bug.
Yeah, it seems that you need to set up an SSL certificate in your domain. In localhost it will run fine, but, in order for a service worker to start, it must come from a secure origin meaning it has to come through the "https" protocol
solved this problem by changing the file firebase.js on line : return navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"})
change : return navigator.serviceWorker.register("firebase-messaging-sw.js",{scope:"firebase-cloud-messaging-push-scope"})
and I made a folder firebase-cloud-messaging-push-scope with firebase.js files in it
@karsa87 The better solution is to do as you are and call useServiceWorker() to use a service worker if the location of the service worker file is a problem: https://firebase.google.com/docs/reference/js/firebase.messaging.Messaging#useServiceWorker
@gauntface thank you, for your suggestion. it worked well.
Hello i'm having the same issue FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script. (messaging/failed-serviceworker-registration). at http://localhost:5000/__/firebase/3.8.0/firebase.js:544:225
I have my firebase-messaging-sw.js file in a root directory and it still giving me a error, what is the problem? Please help