Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Messaging works only from localhost

I have implemented the Firebase Cloud Messaging - Push Notifications to my spring-boot web application. Everything works fine, until I needed to deploy my application to a web server or run it from another domain in my network. Even when I try to open :port instead of localhost:8080, the firebase-messaging is not recognized..

I receive the following error messages in the console:

{code: "messaging/unsupported-browser", message: "Messaging: This browser doesn't support the API's …he firebase SDK. (messaging/unsupported-browser).", stack: "FirebaseError: Messaging: This browser doesn't sup… at http://192.168.1.3:8080/js/FireBase.js:14:28"}code: "messaging/unsupported-browser"message: "FirebaseError: Messaging: This browser doesn't support the API's required to use the firebase SDK. (messaging/unsupported-browser).↵ at Object.messaging (https://www.gstatic.com/firebasejs/5.7.0/firebase-messaging.js:1:35551)

Uncaught ReferenceError: messaging is not defined..

FireBase.js line 14 is:

// Retrieve the FireBase Messaging object.
const messaging = firebase.messaging();

I am searching the whole day about it, but I couldn't find any adequate solution..

I would be very thankful to any suggestions!

like image 948
Georgi Avatar asked Jun 23 '26 22:06

Georgi


1 Answers

There are some instances that you need to check. First, make sure your browser is up to date. Second, test Firebase without any extensions on your browser especially on Chrome. Third, When going online, Prefer HTTPS instead of HTTP. So it comes with the SSL related issue.

Please see the code that checks if the browser has the necessary APIs firebase-js-sdk-

PS: To test it immediately, just insert your code inside Try/Catch.

[edit]: If you don't want to make a try/catch statement, please consider this

like image 116
Roshan Avatar answered Jun 26 '26 10:06

Roshan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!