Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Push notifications sent with FCM are missing fields for Android #8310

Open
2 tasks done
MHEien opened this issue Jun 22, 2024 · 3 comments
Open
2 tasks done
Assignees
Labels
bug Something isn't working product / messaging Fixes and upgrades for the Appwrite Messaging. question Further information is requested stale

Comments

@MHEien
Copy link

MHEien commented Jun 22, 2024

馃憻 Reproduction steps

Send a message in Appwrite Console to an Android app.
Keep the app in foreground, and take a look at the received notification.

This is tested on Expo managed applications using the expo-notifications package.

馃憤 Expected behavior

I've been troubleshooting this for a bit, and found that the payload sent to FCM services is missing a data field in the object.
While taking a brief look through the UTOPIA PHP adapter used for messaging in Appwrite, specifically in the FCM class, I noticed this is indeed the case.
The class is found here: https://github.com/utopia-php/messaging/blob/main/src/Utopia/Messaging/Adapter/Push/FCM.php

Take a look at the bare example of the expected payload below, to see which fields are mapped to which Application state.

{
  "message": {
    "token": "some-token",
    "notification": {
        "title": "Works in background",
        "body": "This message is successfully received while app is in background."
      },
    "android": {
      "priority": "high",
      "data": {
        "title": "This title is visible while the app is in foreground.",
        "message": "This message will be seen in the push notification while the app is in foreground."
      }
    },
    "data": {
      "href": "chat"
    }
  }
}

馃憥 Actual Behavior

When sending a Push notification to Android devices, the push notification is received, but will not contain any content while the app is in foreground. Including android.data will fix this.

Discord thread: https://discord.com/channels/564160730845151244/1254059230751625217

馃幉 Appwrite version

Version 1.5.x

馃捇 Operating system

Linux

馃П Your Environment

1.5.5

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@MHEien MHEien added the bug Something isn't working label Jun 22, 2024
@stnguyen90 stnguyen90 added the product / messaging Fixes and upgrades for the Appwrite Messaging. label Jun 26, 2024
@stnguyen90 stnguyen90 self-assigned this Jun 26, 2024
@stnguyen90
Copy link
Contributor

@MHEien, thanks for creating this issue! 馃檹馃徏

As mentioned on Discord, this seems like a bug either client-side or with react native. Here's my test on Android (Flutter) with the app in the foreground:

image

image

the code i tested with: https://github.com/firebase/flutterfire/tree/master/packages/firebase_messaging/firebase_messaging/example

@stnguyen90 stnguyen90 added the question Further information is requested label Jun 26, 2024
@MHEien
Copy link
Author

MHEien commented Jun 28, 2024

Ok thanks, I've read up on how push notifications works on the device, and found that messages received while the app is in foreground is indeed controlled by the app. I suppose I'll have to wait for Expo to have this fixed then. However, if anybody else encounter this issue aswell, adding the title and message to android.data path would solve this issue completely.

Copy link

github-actions bot commented Jul 6, 2024

This issue has been labeled as a 'question', indicating that it requires additional information from the requestor. It has been inactive for 7 days. If no further activity occurs, this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / messaging Fixes and upgrades for the Appwrite Messaging. question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

2 participants