Reputation: 176
I am trying to implement FCM push notification. And my firefox version is 63.0.
Below is my code,
var config = {
apiKey: "${model.apiKey}",
authDomain: "${model.authDomain}",
databaseURL: "${model.databaseURL}",
projectId: "${model.projectId}",
storageBucket: "${model.storageBucket}",
messagingSenderId: "${model.messagingSenderId}"
};
firebase.initializeApp(config)
const messaging = firebase.messaging();
messaging.requestPermission().then(function () {
console.log("Notification permission granted.");
// get the token in the form of promise
return messaging.getToken()
}).then(function(token) {
$('#devicekey').val(token);
}).catch(function (err) {
console.log("Unable to get permission to notify.", err);
});
Notification permission granted
is showing in the console. But showing an error
FirebaseError: Messaging: This browser doesn't support the API's required to use the firebase SDK. (messaging/unsupported-browser).
So that I can't get the token.Why is this so? Please note that am running my application over 'http'.
Upvotes: 4
Views: 4797
Reputation: 701
The FCM SDK is supported only in pages served over HTTPS. This is due to its use of service workers, which are available only on HTTPS sites. Need a provider? Firebase Hosting is an easy way to get free HTTPS hosting on your own domain.
In my Firefox 63 I saw message like yours when I tried to open a page with firebase initialization via http. My Chrome writes more specifically warning in this case:
[Deprecation] The Notification API may no longer be used from insecure origins. You should consider switching your application to a secure origin, such as HTTPS.
Also I saw message like yours when I worked in Firefox 60 by https. The reason is that "service workers" disabled on Firefox 60 ESR (but can be re-enabled). This message is too general in Firefox.
Upvotes: 5