I have a Cloud Functions environment that sends data and notification messages.
At the moment, I am testing FCM messages on an iPhone SE (2016) and an iPhone 7 Plus - and the behaviour is very inconsistent between the 2 devices and I'd like to know why.
- iPhone SE (2016) is running iOS 14 beta 1
- iPhone 7 Plus is running iOS 14 beta 3
The following cloud function sends a notification and data message - both of these successfully get delivered to both devices:
// These options are global for all my fcm messages
const options = { priority: "high", timeToLive: 30000, content_available: true }
function sendProfile() {
...
const fcmToken = ********
const notif = {
notification: {
title: "test title",
body: "test body"
}
}
admin.messaging().sendToDevice(fcmToken, notif, options);
const dataMsg = {
data: {
id: id,
type: "match",
uid: uid,
name: name,
age: age.toString(),
bio: bio,
img1: String(img1),
img2: String(img2),
img3: String(img3),
pronoun: pronoun,
error: String(bot)
}
}
return admin.messaging().sendToDevice(fcmToken, dataMsg, options);
}
However for the following function:
The notification message successfully gets delivered to both devices
But the data message only gets delivered to the iPhone SE (not the iPhone 7 Plus)
function sendPlace(fcmToken, placeSnapshot, matchName){ let docId = placeSnapshot.id; let place = placeSnapshot.data(); console.log("sendPlacee: ", place.name, " to: ", fcmToken); const dataMsg = { data: { type: "place", name: place.name, latitude: place.l.latitude.toString(), longitude: place.l.longitude.toString(), instruction: String(place.instruction), placeId: docId, picture: String(place.picture1), matchName: matchName, address: place.address } } const notif = { notification: { title: "test place function", body: "test the body message" } } admin.messaging().sendToDevice(fcmToken, notif, options) return admin.messaging().sendToDevice(fcmToken, dataMsg, options) }
Only when I remove some of the payload, it successfully sends to the iPhone 7 Plus (I removed the instruction
, picture
and address
key values from the data payload - and then it worked).
Any idea what the problem is here?
Edit: There are no problems with my Android devices.