0

Hello everyone I hope you're all doing great. I have created a React native application and implemented react native firebase. I have a react.js application that sends notifications to devices(all platforms) using their tokens. Everything works well on huawei and android devices but on ios it didn't work. I am using an ios simulator. and the code that sends the notifications is this:

tokens.forEach(t => {
            fetch("https://fcm.googleapis.com/fcm/send", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    "Authorization": API_KEY,
                },
                body: JSON.stringify({
                     "to": t.device_token,
                    "data": {
                        codeArticle: document.getElementById("input-code-article").value,
                        typeArticle: document.getElementById("select-type-article").value
                    },
                    "notification": {
                        "title": document.getElementById("input-title").value,
                        "body": document.getElementById("input-body").value,
                        "sound": "notification",
                    },
                }),
            })
                .then(res => res.json())
                .then(res => console.log("res notific: ",res))
                .catch(error => console.log(error));
         });

I am sure that all the configuration steps are nicely done and the problem is with the post request payload.

Help please!

0 Answers0