Firebase Cloud Messaging (FCM) sends push notification to System tray AND app callback when foregrounded

Context

As per the FCM documentation on Android Message Handling, push notifications will only be displayed if the App is backgrounded. It is not possible for a notification to appear in the System Tray while the App is foregrounded.

However! I have an app built with Capacitor. The app is currently on beta using the Internal Testing tool suite of the playstore. On it, when sending push notifications, I receive them through the onMessageReceived callback AND the System Tray even when the app is foregrounded.

According to the documentation, that shouldn’t be possible. So, I thought maybe (without being able to confirm):

  • Did I read the FCM documentation wrong?
  • The Internal Testing is preventing FCM from correctly detecting if an app is foregrounded (although I don’t think so, since onMessageReceived get triggered)
  • Something is wrong with Capacitor (I am using an old and unsupported version, so I wouldn’t be surprised of unintended behaviour)
  • Something wrong about the FCM message format I’m sending (see below)?

An example of the FCM message package I’m sending using the firebase-admin SDK (latest version). This is a notification message with the optional data payload provided:

{
  data: { // data },
  notification: { title: "My title", body: 'My body' },
  android: { notification: { priority: 'max', visibility: 'public' } },
  apns: { payload: { aps: [Object] } },
  tokens: // token
}

Some observations:

  • On iOS (Capacitor being cross-platform), I get the same behaviour with a notification in the System Tray and the callback triggered
  • On Android, notifications that appear when the app is foregrounded are not clickable
  • When the app is backgrounded, I get notifications in the System Tray as expected. Those work as intended and are clickable (eg. they open the app and trigger the correct callbacks)
  • I just updated from a very old firebase-admin SDK (that was using the now-closed legacy APIs) to the latest version of the SDK. Before, I didn’t have this kind of issues.

My question (finally)

  • Is this issue caused by the Internal Testing? If so, that would indicate to me that the live version will work as expected
  • If not, did you ever encounter this issue? If so, did you fix it and how?
  • If not, do you have an idea what could be the issue?

What I tried

  • I’ve tried removing the android.notification.priority and .visibility props, but I get the same issue.
  • All the research I’ve done point to topics and posts discussing if it was possible to send a notification to the System Tray while the app is foregrounded. While I am in that situation, but want to get out of it (truly ironic).

If you need to get onMessageReceived when the app is in foreground and background, You should send notification object as null and use data object for sending data as follows

{
  data: {  title: "My title", body: 'My body' },
  notification: null,
  android: { notification: { priority: 'max', visibility: 'public' } },
  apns: { payload: { aps: [Object] } },
  tokens: // token
}

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Firebase Cloud Messaging (FCM) sends push notification to System tray AND app callback when foregrounded

Context

As per the FCM documentation on Android Message Handling, push notifications will only be displayed if the App is backgrounded. It is not possible for a notification to appear in the System Tray while the App is foregrounded.

However! I have an app built with Capacitor. The app is currently on beta using the Internal Testing tool suite of the playstore. On it, when sending push notifications, I receive them through the onMessageReceived callback AND the System Tray even when the app is foregrounded.

According to the documentation, that shouldn’t be possible. So, I thought maybe (without being able to confirm):

  • Did I read the FCM documentation wrong?
  • The Internal Testing is preventing FCM from correctly detecting if an app is foregrounded (although I don’t think so, since onMessageReceived get triggered)
  • Something is wrong with Capacitor (I am using an old and unsupported version, so I wouldn’t be surprised of unintended behaviour)
  • Something wrong about the FCM message format I’m sending (see below)?

An example of the FCM message package I’m sending using the firebase-admin SDK (latest version). This is a notification message with the optional data payload provided:

{
  data: { // data },
  notification: { title: "My title", body: 'My body' },
  android: { notification: { priority: 'max', visibility: 'public' } },
  apns: { payload: { aps: [Object] } },
  tokens: // token
}

Some observations:

  • On iOS (Capacitor being cross-platform), I get the same behaviour with a notification in the System Tray and the callback triggered
  • On Android, notifications that appear when the app is foregrounded are not clickable
  • When the app is backgrounded, I get notifications in the System Tray as expected. Those work as intended and are clickable (eg. they open the app and trigger the correct callbacks)
  • I just updated from a very old firebase-admin SDK (that was using the now-closed legacy APIs) to the latest version of the SDK. Before, I didn’t have this kind of issues.

My question (finally)

  • Is this issue caused by the Internal Testing? If so, that would indicate to me that the live version will work as expected
  • If not, did you ever encounter this issue? If so, did you fix it and how?
  • If not, do you have an idea what could be the issue?

What I tried

  • I’ve tried removing the android.notification.priority and .visibility props, but I get the same issue.
  • All the research I’ve done point to topics and posts discussing if it was possible to send a notification to the System Tray while the app is foregrounded. While I am in that situation, but want to get out of it (truly ironic).

If you need to get onMessageReceived when the app is in foreground and background, You should send notification object as null and use data object for sending data as follows

{
  data: {  title: "My title", body: 'My body' },
  notification: null,
  android: { notification: { priority: 'max', visibility: 'public' } },
  apns: { payload: { aps: [Object] } },
  tokens: // token
}

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Firebase Cloud Messaging (FCM) sends push notification to System tray AND app callback when foregrounded

Context

As per the FCM documentation on Android Message Handling, push notifications will only be displayed if the App is backgrounded. It is not possible for a notification to appear in the System Tray while the App is foregrounded.

However! I have an app built with Capacitor. The app is currently on beta using the Internal Testing tool suite of the playstore. On it, when sending push notifications, I receive them through the onMessageReceived callback AND the System Tray even when the app is foregrounded.

According to the documentation, that shouldn’t be possible. So, I thought maybe (without being able to confirm):

  • Did I read the FCM documentation wrong?
  • The Internal Testing is preventing FCM from correctly detecting if an app is foregrounded (although I don’t think so, since onMessageReceived get triggered)
  • Something is wrong with Capacitor (I am using an old and unsupported version, so I wouldn’t be surprised of unintended behaviour)
  • Something wrong about the FCM message format I’m sending (see below)?

An example of the FCM message package I’m sending using the firebase-admin SDK (latest version). This is a notification message with the optional data payload provided:

{
  data: { // data },
  notification: { title: "My title", body: 'My body' },
  android: { notification: { priority: 'max', visibility: 'public' } },
  apns: { payload: { aps: [Object] } },
  tokens: // token
}

Some observations:

  • On iOS (Capacitor being cross-platform), I get the same behaviour with a notification in the System Tray and the callback triggered
  • On Android, notifications that appear when the app is foregrounded are not clickable
  • When the app is backgrounded, I get notifications in the System Tray as expected. Those work as intended and are clickable (eg. they open the app and trigger the correct callbacks)
  • I just updated from a very old firebase-admin SDK (that was using the now-closed legacy APIs) to the latest version of the SDK. Before, I didn’t have this kind of issues.

My question (finally)

  • Is this issue caused by the Internal Testing? If so, that would indicate to me that the live version will work as expected
  • If not, did you ever encounter this issue? If so, did you fix it and how?
  • If not, do you have an idea what could be the issue?

What I tried

  • I’ve tried removing the android.notification.priority and .visibility props, but I get the same issue.
  • All the research I’ve done point to topics and posts discussing if it was possible to send a notification to the System Tray while the app is foregrounded. While I am in that situation, but want to get out of it (truly ironic).

If you need to get onMessageReceived when the app is in foreground and background, You should send notification object as null and use data object for sending data as follows

{
  data: {  title: "My title", body: 'My body' },
  notification: null,
  android: { notification: { priority: 'max', visibility: 'public' } },
  apns: { payload: { aps: [Object] } },
  tokens: // token
}

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật