Skip to content

FirebaseMessaging.MessageReceived triggers multiple times on receiving single push notification #1339

Closed
@Grimshady

Description

@Grimshady

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.43f1
  • Firebase Unity SDK version: 11.0.0
  • Source you installed the SDK: Unity Package Manager
  • Problematic Firebase Component: Cloud Messaging
  • Other Firebase Components in use: App (Core)
  • Additional SDKs you are using: None
  • Platform you are using the Unity editor on: iOS
  • Platform you are targeting: iOS
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

When triggering a push notification through POSTMAN having the following payload with the app in foreground, the FirebaseMessaging.MessageReceived event apparently fires 4 times.

The same is observed when app is in background and notification is tapped to resume the app.

{
    "data": {
        "typ": 13,
        "s_typ": 1,
        "cid": 1000,
        "pid": "payload_id"
    },
    "notification":
    {
      "title":"NotifTitleTest1",
      "body":"NotifBodyTest1"
    },
    "content_available": true,
    "mutable_content": true,
    "to": "czCPSW2Ar0Lwrf2D9CCz1w:APA91bFQg1Fgadw71fWx9WJo6WzfqFZ-81s8_Ff5_-dQwE7w9Fu2E96cciW49BMTU3vu4hJqFZDm5SuU_ettSKURRC0rdg7TTaHaIUO-vE_WKj_rfrI03ODklUz61TTiBmdrurBD-TTK"
}

I have double checked for multiple Monobehavior instances and subscriptions and all seems fine on this regard. I am even unsubscribing wherever I am subscribing to the events.

Attached screenshot where I am logging MessageID. Logs are printed multiple times with the same MessageID:
Screenshot 2023-06-19 at 6 04 33 PM

Steps to reproduce:

  • Build for iOS
  • Deploy to Xcode and build
  • Use generated token to send notifications via POSTMAN while app is in foreground
  • MessageReceived event triggers multiple times

Relevant Code:
Attached main FCM helper script:
RemoteNotificationReceiver.cs.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions