Home / IOS Development / ildbase – Some types of FCM data messages are not delivered to iOS device

ildbase – Some types of FCM data messages are not delivered to iOS device



I have a Cloud Functions environment that sends data and notification messages.

I am currently testing FCM messages on an iPhone SE (201

6) and an iPhone 7 Plus – and the behavior is very inconsistent between the two devices, and I would like to know why.

  • iPhone SE (2016) runs iOS 14 beta 1
  • iPhone 7 Plus runs iOS 14 beta 3

The following cloud feature sends an alert and data message – both of which are 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:

  1. The notification message is delivered to both devices

  2. But the data message is only delivered to iPhone SE (not 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 is sent to the iPhone 7 Plus (I removed instruction, picture and address key values ​​from the payload – and so it worked).

Any idea what the problem is here?


Source link