firebase / firebase/firebase-admin-go

firebase admin sdk build error

Open
#504 1 comment 0 reactions 0 assignees View on GitHub
api: messaging
Dominant language
Go
Stars
1.3k
Forks
274
Avg merge
10h 39m
Merged PRs (30d)
2

Description

### Environment

* Operating System version: macOS Monterey Version 12.4
* Firebase SDK version: 4.8.0/ 3.13.0
* Firebase Product: messaging

### Problem

Getting the following on running go build main.go
vendor/github.com/firebase/firebase-admin-go/firebase.go:31:2: use of internal package firebase.google.com/go/internal not allowed

The error seems correct according to the [document](https://docs.google.com/document/d/1e8kOo3r51b2BWtTs_1uADIA5djfXhPT36s6eHVRIvaU/edit) but then why is the internal package functions of firebase.google.com/go used in the admin sdk.

#### Steps to reproduce:

Failed to build and run the project for sending push notifications.
1. Add the main.go file in the project.
2. run the commands: go mod init, go mod tidy, go mod vendor

#### Relevant Code:
tried with go version: 1.14, 1.17

main.go

```
package main

import (
"context"
"firebase.google.com/go/messaging"
"fmt"
"github.com/firebase/firebase-admin-go"
"log"
)

func main() {
ctx := context.Background()
app, err := firebase.NewApp(context.Background(), nil, nil)
if err != nil {
log.Fatalf("error initializing app: %v\n", err)
}
client, err := app.Messaging(ctx)
if err != nil {
log.Fatalf("error getting Messaging client: %v\n", err)
}
registrationTokens := []string{
"YOUR_REGISTRATION_TOKEN_1",
"YOUR_REGISTRATION_TOKEN_n",
}
message := &messaging.MulticastMessage{
Data: map[string]string{
"score": "850",
"time": "2:45",
},
Tokens: registrationTokens,
}
br, err := client.SendMulticast(context.Background(), message)
if err != nil {
log.Fatalln(err)
}
fmt.Printf("%d messages were sent successfully\n", br.SuccessCount)

}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.