Skip to content

[Firebase_messaging]: On iOS, subsequent notifications with same collapse ID do not trigger onMessage listener in foreground #17028

Open
@kilobitter

Description

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Messaging

Which platforms are affected?

iOS

Description

As the title states, in our app (and seemingly in general), if we send several notifications with the same collapse ID (So that the notifications collapse to a single one in the notification centre), in Android this works as expected, the notifications collapse into one but if the app is in the foreground the onMessage listener gets triggered with every push notification.

On iOS however, only the first of these notifications triggers the listener. All subsequent notifications do generate a notification in the notification centre, but the listener does not get triggered anymore, unless the collapse ID is changed.

Reproducing the issue

  1. Create an app with Firebase_messaging support on any Apple device
  2. Have an instance of firebaseMessenger.onMessage.listen() that prints a message to the console
  3. From your back-end, send an FCM push notification with a certain "apns-collapse-id"
  4. It triggers the listener
  5. Send another notification with the same "apns-collapse-id"
  6. The listener does not get triggered anymore

Firebase Core version

3.10.0

Flutter Version

3.24.0

Relevant Log Output

n/a

Flutter dependencies

Expand Flutter dependencies snippet
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.5
  path_provider: ^2.0.12
  http: ^1.1.0
  community_charts_flutter: ^1.0.1
  shared_preferences: ^2.0.17
  flutter_material_color_picker: ^1.1.0+2
  # validate: ^1.7.0  # not very good package
  firebase_core: ^3.10.0
  firebase_analytics: ^11.4.1
  firebase_messaging: ^15.2.1
  image_picker: ^1.0.4
  flutter_image_compress: 1.1.3
  permission_handler: ^11.3.1
  image: ^4.2.0
  # exif: ^1.0.1
  #transparent_image: ^1.0.0
  #image_gallery_saver: ^1.1.0
  url_launcher: ^6.3.0
  intl: ^0.19.0
  font_awesome_flutter: ^10.4.0
  flutter_launcher_icons: ^0.13.1  # for flutter icon
  dio: ^5.0.0
  audioplayers: ^6.0.0
  devicelocale: ^0.7.0
  flutter_html: ^3.0.0-beta.2
  encrypt: ^5.0.1
  flutter_secure_storage: ^8.0.0  # TODO
  package_info_plus: ^8.0.0
  store_redirect: ^2.0.1
  youtube_player_flutter: ^9.1.1
  math_expressions: ^2.3.1
  photo_view: ^0.14.0
  fluttertoast: ^8.2.1 # TEST from 4.
  flip_card: ^0.7.0
  flutter_time_picker_spinner: ^2.0.0 # COPIED FROM FUNCTION
  connectivity_plus: ^6.0.3
  pull_to_refresh: ^2.0.0
  spritewidget: ^2.0.1
  vibration: ^1.7.6
  flutter_svg: 2.0.7
  qr_code_scanner: ^1.0.1
  mobile_scanner: ^6.0.2
  flutter_math_fork: ^0.7.1
  # better_player: ^0.0.84
  get: ^4.6.5
  pie_chart: ^5.3.2
  badges: ^3.0.2
  # marquee: ^2.2.3
  auto_size_text: ^3.0.0
  video_player: ^2.5.2
  flutter_sound: ^9.6.0
  device_info_plus: ^9.0.3
  mockito: ^5.3.2
  provider: ^6.0.5
  audio_session: ^0.1.13
  cached_network_image: ^3.2.3
  flutter_chat_ui: ^1.6.6
  geolocator: ^11.0.0
  usage_stats: ^1.2.0
  pedometer: ^4.0.1
  noise_meter: ^5.0.2
  vibration_web: ^1.6.5
  webview_flutter: ^3.0.4
  flutter_blue_plus: ^1.33.5
  flutter_inappwebview: ^6.1.4
  flutter_inappwebview_ios: ^1.1.2
  flutter_scatter: ^0.2.0
  eraser: ^2.0.2
  network_info_plus: ^6.0.1
  internal_audio_recorder: ^0.1.6

Additional context and comments

No response

Activity

MichaelVerdon

MichaelVerdon commented on Jan 31, 2025

@MichaelVerdon
Contributor

Hello there, I have not been able to reproduce your issue, the listener still works with further notifications sent with the same "apns-collapse-id" when it is clicked on. I can suggest upgrading your dependencies but otherwise an MRE would be helpful.

added
blocked: customer-responseWaiting for customer response, e.g. more information was requested.
and removed
Needs AttentionThis issue needs maintainer attention.
on Jan 31, 2025
google-oss-bot

google-oss-bot commented on Feb 11, 2025

@google-oss-bot

Hey @kilobitter. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

frankmer

frankmer commented on Feb 19, 2025

@frankmer

I have the same problem only on iOS, but no notification triggers onMessage.

I am using the following versions:

  firebase_core:
    dependency: "direct main"
    description:
      name: firebase_core
      sha256: "6a4ea0f1d533443c8afc3d809cd36a4e2b8f2e2e711f697974f55bb31d71d1b8"
      url: "https://pub.dev"
    source: hosted
    version: "3.12.0"
  firebase_core_platform_interface:
    dependency: transitive
    description:
      name: firebase_core_platform_interface
      sha256: d7253d255ff10f85cfd2adaba9ac17bae878fa3ba577462451163bd9f1d1f0bf
      url: "https://pub.dev"
    source: hosted
    version: "5.4.0"
  firebase_messaging:
    dependency: "direct main"
    description:
      name: firebase_messaging
      sha256: "8755a083a20bac4485e8b46d223f6f2eab34e659a76a75f8cf3cded53bc98a15"
      url: "https://pub.dev"
    source: hosted
    version: "15.2.3"
  firebase_messaging_platform_interface:
    dependency: transitive
    description:
      name: firebase_messaging_platform_interface
      sha256: "8cc771079677460de53ad8fcca5bc3074d58c5fc4f9d89b19585e5bfd9c64292"
      url: "https://pub.dev"
    source: hosted
    version: "4.6.3"

This is the sended message:

fcm_message = {
    "message": {
        "data": data,
        "token": firebase_token,
        "notification": {
            "title": data.get("title"),
            "body": data.get("body")
        },
        "android": {
            "priority": "HIGH",
            "ttl": "120s",,
            "fcm_options": {"analytics_label": "***"}
        },
        "apns": {
            "headers": {
                "apns-priority": "10",
                "apns-push-type": "alert",
                "apns-collapse-id": "***",
                "apns-expiration": str(int(time.time()) + 120)
            },
            "payload": {
                "aps": {
                    "alert": {
                        "title": data.get("title"),
                        "body": data.get("body"),
                    },
                    "sound": "default",
                    "category": "***"
                },
            },
            "fcm_options": {"analytics_label": "***"}
        }
    }
}

On older versions it worked!

google-oss-bot

google-oss-bot commented on Feb 28, 2025

@google-oss-bot

Hey @kilobitter. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

StaleIssue with no recent activityblocked: customer-responseWaiting for customer response, e.g. more information was requested.platform: iosIssues / PRs which are specifically for iOS.plugin: messagingtype: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    [Firebase_messaging]: On iOS, subsequent notifications with same collapse ID do not trigger onMessage listener in foreground · Issue #17028 · firebase/flutterfire