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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Firebase Cloud Messaging Quickstart] Should be updated to use Firebase Cloud Messaging API (V1) #700

Open
visuallization opened this issue Mar 22, 2023 · 0 comments

Comments

@visuallization
Copy link

Step 1: Describe your environment

  • Operating system: maxOS Ventura
  • Browser: Chrome
  • Firebase SDK version: 9.18.0

Step 2: Describe the problem:

As Firebase Cloud Messaging API (V1) is now enabled by default, the tutorial does not work anymore out of the box with the new API as there won't be a server key to use. You can still follow the tutorial though if you enable the Cloud Messaging API (Legacy) but this would need to be documented.

Steps to reproduce:

  1. Follow the tutorial in [quickstart-js/messaging](https://github.com/firebase/quickstart-js/messaging/)
  2. See the curl request will throw the error INVALID_KEY or PROJECT_NOT_PERMITTED

Observed Results:

Running the proposed command:

curl -X POST -H "Authorization: key=YOUR-SERVER-KEY" -H "Content-Type: application/json" -d '{
  "notification": {
    "title": "Portugal vs. Denmark",
    "body": "5 to 1",
    "icon": "firebase-logo.png",
    "click_action": "http://localhost:8081"
  },
  "to": "YOUR-IID-TOKEN"
}' "https://fcm.googleapis.com/fcm/send"

will throw the error INVALID_KEY or PROJECT_NOT_PERMITTED

Expected Results:

Have 2 messaging examples. One working with Cloud Messaging API (Legacy) and the other working with Firebase Cloud Messaging API (V1). Provide enough relevant information to make the examples work out of the box.

Relevant Code:

Follow the instructions in [quickstart-js/messaging](https://github.com/firebase/quickstart-js/messaging/) with a new Firebase project.

Run:

curl -X POST -H "Authorization: key=YOUR-SERVER-KEY" -H "Content-Type: application/json" -d '{
  "notification": {
    "title": "Portugal vs. Denmark",
    "body": "5 to 1",
    "icon": "firebase-logo.png",
    "click_action": "http://localhost:8081"
  },
  "to": "YOUR-IID-TOKEN"
}' "https://fcm.googleapis.com/fcm/send"

See it returns INVALID_KEY or PROJECT_NOT_PERMITTED.

If anyone else comes across this issue: This medium article helped me making Firebase Cloud Messaging API (V1) work: https://apoorv487.medium.com/testing-fcm-push-notification-http-v1-through-oauth-2-0-playground-postman-terminal-part-2-7d7a6a0e2fa0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant