forked from NdoleStudio/httpsms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (31 loc) · 742 Bytes
/
main.go
File metadata and controls
37 lines (31 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"context"
"log"
"os"
"time"
"firebase.google.com/go/messaging"
"github.com/NdoleStudio/httpsms/pkg/di"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load("../../.env")
if err != nil {
log.Fatal("Error loading .env file")
}
container := di.NewContainer(os.Getenv("GCP_PROJECT_ID"), "")
client := container.FirebaseMessagingClient()
result, err := client.Send(context.Background(), &messaging.Message{
Data: map[string]string{
"KEY_HEARTBEAT_ID": time.Now().UTC().Format(time.RFC3339),
},
Android: &messaging.AndroidConfig{
Priority: "high",
},
Token: os.Getenv("FIREBASE_TOKEN"),
})
if err != nil {
container.Logger().Fatal(err)
}
container.Logger().Info(result)
}