|
@@ -12,27 +12,51 @@ import (
|
|
|
|
|
|
func TestFirebaseMessageServer_Send(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
|
- conf := &firebase.Config{ServiceAccountID: iosFirebaseServiceAccountID}
|
|
|
+ conf := &firebase.Config{ServiceAccountID: androidFirebaseServiceAccountID}
|
|
|
app, err := firebase.NewApp(ctx, conf,
|
|
|
- option.WithCredentialsJSON([]byte(iosFirebaseCredentials)))
|
|
|
+ option.WithCredentialsJSON([]byte(androidFirebaseCredentials)))
|
|
|
if err != nil {
|
|
|
log.Fatalln(err)
|
|
|
}
|
|
|
-
|
|
|
+ //token := "fDfRE2raSkSfroIw47qSEV:APA91bF4LORpS8ZWo-i8i1DQ8SZ8C-BEdFWBdGQGDW-PwzQUivoNf75_NpTrFNLFlAqdHd4mdauaI9aZWhFs4Pou2iySmuI6Ct0sHs5Bc9LrnGMK9f5YEBA"
|
|
|
token := "cl7mDFUw5URmvG9Jio2p7L:APA91bH4GIRM1IJNDn7_tYw7q4ADVdzQKpnaPNqxXw6PZE-H9H82sGkF74-KSz7moydB6ykgHucrXNjsSopmyFCi3M4S-SVWZA_fGJa6Q0WO6V_CY_gtDhi2WHGobM84Pm0aZ0AHb2XB"
|
|
|
clt, err := app.Messaging(ctx)
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
|
+ jsonStr := "hello word"
|
|
|
+ title := "测试消息"
|
|
|
+ body := "测试消息内容,无需关注"
|
|
|
|
|
|
+ //title:= "Call Notification"
|
|
|
+ //body:= "click to view"
|
|
|
+ //videoCallMessage := &NatsPubVideoCallMessage{
|
|
|
+ // AccountId: "954d38fc-f4a4-445f-88e3-7be83a51a3c8",
|
|
|
+ // Dial: 1,
|
|
|
+ // Receiver: "c2686cac-8ec8-4b26-8e87-50b7d63a7d36",
|
|
|
+ // Sender: "954d38fc-f4a4-445f-88e3-7be83a51a3c8",
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //message := NatsPubMessage[NatsPubVideoCallMessage]{
|
|
|
+ // RequestId: "41a83fe2-6281-4f72-bb80-067fb5e19b1c",
|
|
|
+ // Type: MessageTypeVideoCall,
|
|
|
+ // Content: videoCallMessage,
|
|
|
+ //}
|
|
|
+ //jsonBytes, err := json.Marshal(message)
|
|
|
+ //if err != nil {
|
|
|
+ // fmt.Println("Error marshaling JSON:", err)
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //jsonStr := string(jsonBytes)
|
|
|
msg := &messaging.Message{
|
|
|
Token: token,
|
|
|
Data: map[string]string{
|
|
|
- "message": "hello word",
|
|
|
+ "message": jsonStr,
|
|
|
},
|
|
|
Android: &messaging.AndroidConfig{
|
|
|
Notification: &messaging.AndroidNotification{
|
|
|
- Sound: "default",
|
|
|
+ Sound: "default",
|
|
|
+ Priority: messaging.PriorityHigh,
|
|
|
},
|
|
|
},
|
|
|
APNS: &messaging.APNSConfig{
|
|
@@ -43,8 +67,8 @@ func TestFirebaseMessageServer_Send(t *testing.T) {
|
|
|
},
|
|
|
},
|
|
|
Notification: &messaging.Notification{
|
|
|
- Title: "测试消息",
|
|
|
- Body: "测试消息内容,无需关注",
|
|
|
+ Title: title,
|
|
|
+ Body: body,
|
|
|
},
|
|
|
}
|
|
|
|