I am trying to send an FCM topic message to my React Native mobile app, but they don't seem to be going through. I am using NodeJs as follows and logging the output to show that the message is getting sent successfully (no issues with android):
admin
.messaging()
.send({
data: {
title,
body,
lat: data.Location.Latitude.toString(),
lng: data.Location.Longitude.toString(),
},
android: {
priority: "high",
data: {
sound: "alert",
},
},
apns: {
payload: {
aps: {
contentAvailable: true,
},
},
headers: {
'apns-push-type': 'background',
'apns-priority': '5',
'apns-topic': 'com.xxxx',
},
},
topic: topic,
})
The react app is subscribed to the topic as follows:
useEffect(() => {
await requestUserPermissions();
messaging().subscribeToTopic(Config.INCIDENTS_TOPIC);
messaging().onMessage(sendMessage);
messaging().setBackgroundMessageHandler(sendMessage);
});
const sendMessage = (remoteMessage) => {
if (Platform.OS === 'ios') {
notificationRadiusCalculationService.sendMessage(remoteMessage);
}
};
I have set a breakpoint in the sendMessage and its never being hit.My APN was registered in firebase.