flutter – Unable to get collapseKey in rMessage (RemoteMessage) on iOS while using firebase_messaging package


I am sending the following payload to FCM API

{
  message: {
    token: DEVICE_TOKEN,
    apns: {
      headers: {
        'apns-priority': '5',
        'apns-push-type': 'alert',
        'apns-collapse-id': '113',
      },
      payload: {
        aps: {
          alert: {
            title: 'Brand new title',
            body: 'Brand new text',
          },
          category: 'XYZ_CATEGORY',
        },
      },
    },
  },
}

I have written the following background remote notification handler outside of any class as a top-level function in my Flutter app:

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage rMessage) async {
  await Firebase.initializeApp();
  debugPrint('Handling a background message ${rMessage.toMap()}');
}

Here’s the output in the console where the collapseKey is null.

{
  senderId: null,
  category: 'XYZ_CATEGORY',
  collapseKey: null,
  contentAvailable: true,
  data: {},
  from: null,
  messageId: 1706272050712326,
  messageType: null,
  mutableContent: false,
  notification: {
    title: 'Brand new title',
    titleLocArgs: [],
    titleLocKey: null,
    body: 'Brand new text',
    bodyLocArgs: [],
    bodyLocKey: null,
    android: null,
    apple: {
      badge: null,
      subtitle: null,
      subtitleLocArgs: [],
      subtitleLocKey: null,
      imageUrl: null,
      sound: null,
    },
    web: null,
  },
  sentTime: null,
  threadId: null,
  ttl: null,
}

The apns-collapse-id is not mapped to the collapseKey. Is there something missing in my request?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img