I have been working on implementing Push Notifications for web browsers. After allowing permissions in both Chrome and Firefox, the token ID is returned successfully. However, when sending push notifications, they only appear in Chrome and not in Firefox. Below is a snippet of my code:
window.addEventListener('load', function() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js').then(initialiseState);
} else {
console.warn('Service workers aren\'t supported in this browser.');
}
});
function initialiseState()
{
// Code for checking notification support and permissions
}
function subscribe()
{
// Function for subscribing to push notifications
}
Here is the content of the service-worker.js file:
self.addEventListener('push', function(event) {
// Code for handling push events
});
self.addEventListener('notificationclick', function(event) {
// Code for handling notification clicks
});
Sending messages using CURL:
$data = ["registration_ids" => ["token id"]];
// CURL request code here
$response = json_decode($result);
However, despite following these steps, the push notifications are not working in Firefox. Any insights would be greatly appreciated. Thank you!