PWA notifications not working on iOS with FCM even after multiple tries

I am currently utilizing Firebase Cloud Messaging in order to send daily notifications to iOS users who have installed a PWA app. Upon testing, I noticed that each token is limited to receiving only 2 notifications successfully. Any attempt beyond that will show as successful in the logs, but the user does not actually receive the notification. Further testing is required on Android to determine if this issue is specific to iOS.

        const message = {
          notification: {
            title: "Practice Reminder",
            body: "Time for your daily fretboard practice!",
          },
          token: data.token,
        };
        getMessaging().send(message)
        .then((response) => {
          // Response is a message ID string.
          console.log('Successfully sent message:', response);
        })
        .catch((error) => {
          console.log('Error sending message:', error);
        });

Answer №1

On June 2nd, a fix for the issue was proposed and can be found here. The solution involves replacing the onBackgroundMessage with the following code snippet:

self.addEventListener('push', function(event) {
    console.log('[Service Worker] Push Received.');
    const payload = event.data.json();  // Assuming the payload is sent as JSON
    const notificationTitle = payload.notification.title;
    const notificationOptions = {
        body: payload.notification.body,
        icon: payload.notification.icon,
        image: payload.notification.image,
        badge: payload.notification.badge,
    };
    event.waitUntil(
        self.registration.showNotification(notificationTitle, notificationOptions)
    );
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Obtain the total views for a particular map

Looking to optimize my use of the Google Maps JavaScript API. Any suggestions on where I can find information on tracking views and SEO for my map? Appreciate any assistance you can provide. ...

I attempted to log the elements of my submit button form, but unfortunately nothing is appearing in the browser console

I am attempting to capture the data from my submit button form, but for some reason, nothing is showing up in the console of my browser. $("#signupform").submit(function(event){ // Stopped default PHP processing event.preve ...

Show the item in the menu with a label that has either subscript or superscript styling

Within the realm of electrons, the application menu is specified: const menuTemplate = [ { label:"Menu Item 1", click(){ //define some behavior } } ]; Is there a method to exhibit the name of the menu item as Me ...

Detecting User Interaction with Email Link

On my webpage, there is a link that when clicked, opens the default Email client. I also want to track in my database if the user has clicked on this link or not. Since this interaction occurs at the client-side, I am wondering if there is a way to check ...

The selected element does not support the addition of setSelectionRange

I have encountered an error while trying to add the "setSelectionRange" method to an input element that I selected using "getElementById". The error message states that "property 'setselectionrange' does not exist on type 'htmlelement'" ...

Clicking on the image "Nav" will load the div into the designated target and set its display to none. The div will

Can someone help me with loading a div into a target from an onclick using image navigation? I also need to hide the inactive divs, ensuring that only the 1st div is initially loaded when the page loads. I've tried searching for a solution but haven&a ...

What is causing the navbar to malfunction on mobile devices?

I am facing an issue with my bootstrap navbar. It seems to be getting stuck when the screen resizes or when viewed on a mobile device. I have tried several solutions from various sources, but none seem to work. Here are some of the answers that I have look ...

Opt for employing a JavaScript variable over a JSON file

Let's start with a declaration: <div id="timeline-embed"></div> <script type="text/javascript"> var timeline_config = { width: "100%", height: "100%", debug: true, rows: 2, ...

Ensure that the form is submitted only after confirming it in the modal with react-hook-form

**I am facing an issue with submitting react-hook-form on confirm in a modal component. Whenever the user selects confirm, I need the form to be submitted directly. I have tried writing the modal inside FormSubmitButton. Also, I have tried placing it insi ...

Insert the text into a table data cell once the drop-down selection has been changed

I am attempting to display my ajax results in the td element next to my dropdown menu that triggers the ajax call when changed. Each row contains a similar id where I intend for the text to be shown (I'm sure there is a simpler solution). Below is my ...

Using JavaScript, you can open a new/edit page for a custom object and pass parameters by clicking on a

In order to have a custom button on the opportunity page, both the custom object and opportunity pages have been configured with page layouts for new & edit pages, not VF. The goal is to achieve the following: 1) When clicking on the button for the first ...

Unable to iterate through Ajax calls using For Loop when onChange event occurs

I'm struggling with looping the OnChange method using an AJAX call, but for some reason, it's not working as expected. for (let index = 0; index < 300; index++) { $('#txtLini'+[index]).on('change', function() { ...

What is the significance of employing the `var` keyword in Vue.js?

As I dive into tutorials and browse through code snippets while immersing myself in learning this framework, I've noticed a common trend - the use of var for declarations. This practice seems prevalent across resources, including the official Vue docu ...

Show the text area content in an alert when using Code Mirror

When I try to alert the content of a textarea that is being used as a Code Mirror on a button click, it appears blank. However, when I remove the script for Code Mirror, the content displays properly. I am puzzled about what could be causing this issue wi ...

Retrieve a true value by using either Array.some or _.some

I am looking to retrieve a truthy value from the array.Some other than "true", This is my approach: let category; arduair.aqi_ranges[pollutant].some((item,index)=> { let min = item.range[0]; let max = item.range[1]; if (_.inRange(c,min,max)){ ...

Using the OpenGL 4x4 Matrix to translate an object along the X-axis

In my iOS app, I have an object in a 2D scene whose position is defined by a matrix. Vect3F translation = Vect3F(0.0f, 0.0f, 0.0f); Matrix44F translationMatrix({ 1, 0, 0, translation[0], 0, 1, 0, translation[1], 0, 0, 1, translation[2], 0 ...

What steps can be taken to modify this jQuery code so that any changes made are also saved to localStorage

I have successfully used jQuery to change the background color of all my divs with the same class (userNumber1) when I check its checkbox. However, I am now looking for a way to save these changes to localStorage, so that they persist each time the page is ...

Issue with Bootstrap v3.3.6 Dropdown Functionality

previewCan someone help me figure out why my Bootstrap dropdown menu is not working correctly? I recently downloaded Bootstrap to create a custom design, and while the carousel is functioning properly, when I click on the dropdown button, the dropdown-menu ...

does not dynamically update hasAttribute

I am encountering an issue with jQuery Validator on my form. Despite being checked or unchecked, the checked attribute does not change on my validator when I submit the form. Below is the snippet of HTML: <div class="col-sm-10 col-sm-offset-1"> ...

Validating forms with pure JavaScript

Hello, I am currently working on my very first contact form using HTML, Bootstrap, and JavaScript. While I have managed to prevent the form from submission when any input is missing, I am facing an issue with allowing the form submission once all inputs ...