Skip to content

Migrating from legacy FCM to HTTP v1 #173

Open
@shaffe-fr

Description

Hi,

The FCM implementation of this package was deprecated in June 2023 and will be removed in June 2024. We must now use the HTTP v1 API.

https://firebase.google.com/docs/cloud-messaging/migrate-v1

Here are the main changes I identified:

  • We must authenticate using Oauth v2 using credentials stored in a JSON file
  • The endpoint has changed to https://fcm.googleapis.com/v1/projects/<PROJECT_ID>/messages:send
  • It's no longer possible to target multiple devices in the same request, we must send multiple request ourselves.
  • The payload format has changed.
    before:
// Android
{
  "to": "/topics/news",
  "notification": {
    "title": "Breaking News",
    "body": "New news story available.",
    "click_action": "TOP_STORY_ACTIVITY"
  },
  "data": {
    "story_id": "story_12345"
  }
}
// Apple
{
  "to": "/topics/news",
  "notification": {
    "title": "Breaking News",
    "body": "New news story available.",
    "click_action": "HANDLE_BREAKING_NEWS"
  },
  "data": {
    "story_id": "story_12345"
  }
}

after:

{
  "message": {
    "topic": "news",
    "notification": {
      "title": "Breaking News",
      "body": "New news story available."
    },
    "data": {
      "story_id": "story_12345"
    },
    "android": {
      "notification": {
        "click_action": "TOP_STORY_ACTIVITY"
      }
    },
    "apns": {
      "payload": {
        "aps": {
          "category" : "NEW_MESSAGE_CATEGORY"
        }
      }
    }
  }
}

Are you planning to work on this @Edujugon?

Thanks

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions