appleboy / gorush

A push notification server written in Go (Golang).
MIT License
7.84k stars 829 forks source link

Config android apikey vs. payload api_key #741

Closed nevotheless closed 2 months ago

nevotheless commented 1 year ago

Hello! I'm fiddling around with gorush atm and don't seem to understand what the

android:
  enabled: true
  apikey: "YOUR_API_KEY"
  max_retry: 0 # resend fail notification, default value zero is disabled

portion of the config file is for? I assumed i can put my firebase serverkey in there and send requests like

/api/push

{
  "notifications": [
    {
      "tokens": ["token_a", "token_b"],
      "platform": 2,
      "message": "This notification will go to iOS and Android platform via Firebase!"
    }
  ]
}

instead i have to send requests like

{
  "notifications": [
    {
      "api_key": "somefirebaseserverkey",
      "tokens": ["token_a", "token_b"],
      "platform": 2,
      "message": "This notification will go to iOS and Android platform via Firebase!"
    }
  ]
}

to prevent running into 401 authentication issues.

But when i do this, i question what gorush is good for if i have to provide the api_key myself in the payload. Seems like i'm missing some crucial info here.

nevotheless commented 1 year ago

bump

khomin commented 5 months ago

Totally What is this token_a, token_b? I can't find such thing in firebase

Update: I found a way how to run it: 1) in config.yml

android:
  enabled: true
  apikey: "AA***eF" -    "dashboard - Cloud Messaging API (Legacy) Enabled"

2) send

{
  "notifications": [
    {
      "tokens": ["your FCM device token"],
      "platform": 2,
      "message": "Hello World Android!",
      "title": "You got message"
    }
  ]
}
nevotheless commented 5 months ago

That's valuable information!