TL;DR: React native app, sending remote push notifications works for Android, not for iOS.
Hi, I am developing react-native app and trying to send notification to other users after a user makes a specific action. I have no backend, just Firestore and Firebase Cloud Messaging.
For android it works just by sending a POST request from the app like this:
export const sendPushNotification = async (recipientToken, title, body) => {
const FCM_SERVER_KEY =
'AAAA6dAudaoXXXXXXX...XXXXXXXXXwbBaKNh';
const message = {
to: recipientToken,
notification: {
title: title,
body: body,
vibrate: 1,
sound: "default",
show_in_foreground: true,
priority: 'high',
content_available: true,
},
data:{
title: title,
message: body
}
};
let headers = new Headers({
'Content-Type': 'application/json',
Authorization: 'key=' + FCM_SERVER_KEY,
});
/************* this is where the message is sent *********************/
let response = await fetch('https://fcm.googleapis.com/fcm/send', {
method: 'POST',
headers,
body: JSON.stringify(message),
});
};
But for iOS it does not work (even though I have requested notifications permissions). Also it is really hard to test, since I can't send push notification to an emulated iPhone, so I need to release new version after each change.
Any thoughts about this?
Thanks
Edit: Here are picture of my projects capabilities in Xcode and my certificates for notifications on Apple Developer website:


FCM_SERVER_KEYin an app you ship to your clients. Doing so allows anyone who gets access to it to take the key, and use it to send whatever message they want to all your users. As its name implies, the key should only be used on servers or otherwise trusted environments. For more on this, see stackoverflow.com/questions/37990140/… - Frank van Puffelen