capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/firebase/
Apache License 2.0
409 stars 104 forks source link

bug: Android getDeliveredNotifications are missing the data part #763

Open khamaileon opened 5 days ago

khamaileon commented 5 days ago

Plugin(s)

Version

6.2.0

Platform(s)

Current behavior

I send notifications to iOS and Android, always including data (in this specific case: path and trip_id). When I call getDeliveredNotifications, I receive these two pieces of info in the iOS response, but not in the Android response.

iOS:

[
  {
    "id": "765AD00C-A290-4BEA-A217-3B6E6F37AFD3",
    "title": "Paul Smith",
    "subtitle": "",
    "data": {
      "fcm_options": { "image": "https://domain.app/images/icon.svg" },
      "aps": {
        "alert": { "body": "b", "title": "Paul Smith" },
        "mutable-content": 1
      },
      "google.c.fid": "cE5UuzmK1k52uIElXi9HL3",
      "google.c.a.e": "1",
      "google.c.sender.id": "272527473304",
      "path": "/Awe0EyW/messages/dc480249-38e9-47c2-9f8c-2b5205311263",
      "gcm.message_id": "1732535077617442",
      "trip_id": "Awe0EyW"
    },
    "body": "b"
  },
  {
    "id": "D6C4D5CB-1D22-4976-B8BA-C18E06AA2DD4",
    "title": "Paul Smith",
    "subtitle": "",
    "data": {
      "fcm_options": { "image": "https://domain.app/images/icon.svg" },
      "google.c.fid": "cE5UuzmK1k52uIElXi9HL3",
      "aps": {
        "alert": { "body": "a", "title": "Paul Smith" },
        "mutable-content": 1
      },
      "google.c.a.e": "1",
      "gcm.message_id": "1732535076483747",
      "google.c.sender.id": "272527473304",
      "path": "/Awe0EyW/messages/d6fb828f-ea82-4fe5-8ce0-953363006452",
      "trip_id": "Awe0EyW"
    },
    "body": "a"
  }
]

Android:

[
  {
    "id": "2147483647",
    "tag": "ranker_group",
    "data": {
      "android.reduced.images": true,
      "android.appInfo": "ApplicationInfo{b50504a app.domain}"
    }
  },
  {
    "id": "0",
    "tag": "FCM-Notification:3557634",
    "title": "Paul Smith",
    "body": "a",
    "data": {
      "android.title": "Paul Smith",
      "android.reduced.images": true,
      "android.template": "android.app.Notification$BigTextStyle",
      "android.showChronometer": false,
      "android.text": "a",
      "android.progress": 0,
      "androidx.core.app.extra.COMPAT_TEMPLATE": "androidx.core.app.NotificationCompat$BigTextStyle",
      "android.progressMax": 0,
      "android.appInfo": "ApplicationInfo{ce4ebbb app.domain}",
      "android.showWhen": true,
      "android.bigText": "a",
      "android.progressIndeterminate": false
    }
  },
  {
    "id": "0",
    "tag": "FCM-Notification:3558672",
    "title": "Paul Smith",
    "body": "c",
    "data": {
      "android.title": "Paul Smith",
      "android.reduced.images": true,
      "android.template": "android.app.Notification$BigTextStyle",
      "android.showChronometer": false,
      "android.text": "c",
      "android.progress": 0,
      "androidx.core.app.extra.COMPAT_TEMPLATE": "androidx.core.app.NotificationCompat$BigTextStyle",
      "android.progressMax": 0,
      "android.appInfo": "ApplicationInfo{aed88d8 app.domain}",
      "android.showWhen": true,
      "android.bigText": "c",
      "android.progressIndeterminate": false
    }
  },
  {
    "id": "0",
    "tag": "FCM-Notification:3558114",
    "title": "Paul Smith",
    "body": "b",
    "data": {
      "android.title": "Paul Smith",
      "android.reduced.images": true,
      "android.template": "android.app.Notification$BigTextStyle",
      "android.showChronometer": false,
      "android.text": "b",
      "android.progress": 0,
      "androidx.core.app.extra.COMPAT_TEMPLATE": "androidx.core.app.NotificationCompat$BigTextStyle",
      "android.progressMax": 0,
      "android.appInfo": "ApplicationInfo{5e54431 app.domain}",
      "android.showWhen": true,
      "android.bigText": "b",
      "android.progressIndeterminate": false
    }
  }
]

Expected behavior

Data should be in the Android response too.

Reproduction

https://github.com/capawesome-team/.capacitor-app

Steps to reproduce

Sorry, it's complicated to reproduce a complete test environment with a notification send.

Other information

No response

Capacitor doctor

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.2.0 @capacitor/core: 6.2.0 @capacitor/android: 6.2.0 @capacitor/ios: 6.2.0

Installed Dependencies:

@capacitor/cli: 6.2.0 @capacitor/core: 6.2.0 @capacitor/android: 6.2.0 @capacitor/ios: 6.2.0

[success] iOS looking great! 👌 [success] Android looking great! 👌

Before submitting

robingenz commented 5 days ago

Thank you for your request. I'm not sure if this is supported on Android. Would you be willing to debug this yourself?

You just need to place a breakpoint in this line via Android Studio: https://github.com/capawesome-team/capacitor-firebase/blob/29eba4de9ba821d010974e7b57cbf1e63133cc7e/packages/messaging/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/messaging/FirebaseMessagingHelper.java#L78

khamaileon commented 5 days ago

Thank you for your support @robingenz

I set a breakpoint, but I'm not sure what I should look for. When I run the process, nothing stops.

Screenshot 2024-11-25 at 16 18 34
robingenz commented 5 days ago

Please take a look at this guide on how to debug an Android app.

Edit: You need to check that notifications.extras has the values you are looking for. If notifications.extras is empty, then it'sn ot supported on Android via this method.