我尝试将带有标签的消息发送到 fcm,消息正常接收,但 firebase Reports Tab 未找到此标签。
这是我的发送代码(golang):
package main
import (
"context"
"fmt"
firebase "firebase.google.com/go"
"firebase.google.com/go/messaging"
"google.golang.org/api/option"
)
func main() {
opt := option.WithCredentialsFile("./authrization.json")
ctx := context.Background()
app, err := firebase.NewApp(ctx, &firebase.Config{ProjectID: "project-id"}, opt)
if err != nil {
fmt.Printf("error initializing app: %v\n", err)
return
}
c, err := app.Messaging(ctx)
msg := &messaging.Message{
Data: map[string]string{
"reserved_type": "asd",
"reserved_id": "gq",
},
Notification: &messaging.Notification{
Title: "test common",
Body: "asd1asfa",
},
FCMOptions: &messaging.FCMOptions{
AnalyticsLabel: "testcommon",
},
Token: "cEeYSxwqTIee-oJxxxxxxxxx",
}
n, err := c.Send(ctx, msg)
if err != nil {
fmt.Printf("send error: %v\n", err)
return
}
fmt.Printf("response n: %s\n", n)
}
应用中的 Analytics SDK 并启用与 Firebase 的数据共享全部完成。
是我发错了,还是fcm本身有问题?