2
votes

I'm currently trying to implement a server in Go working with Firebase Cloud Messaging. I inserted my API key and sender ID (which I both got from the Firebase console at Project Settings -> Cloud Messaging) and did this:

err := gcm.Listen(senderID, apiKey, onMessageReceived, nil)

and all I get is this

error creating xmpp client>error connecting client>auth failure: not-authorized

I'm using the same library Google's using in it's examples. Is the library maybe not working with FCM yet or am I doing something wrong?

If it's the library, how would I implement this without it?

1
Hi mkocs, I am not able to reproduce this issue. (I tried creating a new project and the library you linked works for me.) Could you please reach out to support and report your sender-id and your api-key ? firebase.google.com/support/contact/bugs-features thanks! - Diego Giorgini
@DiegoGiorgini I already sent a message to support a few hours ago, but without the API key and sender id. Should I just send another? - calmandniceperson
@DiegoGiorgini Could you maybe create a gist with the code of the project you created and send me a link? I'd really appreciate it. Maybe I just made a mistake working with the library. - calmandniceperson
I will follow up there! thanks - Diego Giorgini

1 Answers

1
votes

This library will works perfectly with firebase, if you do several things:

  1. Change xmppHost from https://gcm-http.googleapis.com/gcm/send to https://fcm.googleapis.com/fcm/send
  2. Add new const xmppDomain = "gcm.googleapis.com"
  3. Change function xmppUser, it should be like
func xmppUser(senderId string) string {
    return senderId + "@" + xmppDomain
}