appleboy / gorush

A push notification server written in Go (Golang).
MIT License
7.87k stars 831 forks source link

Sound field not working in version 1.18 #791

Open ZaninAndrea opened 1 week ago

ZaninAndrea commented 1 week ago

We recently upgraded from gorush 1.16 to 1.18.2 (we are using the gRPC api). In the 1.18.2 version the support for the sound field seems to be broken, while it was working in v1.16: we use FCM to send push notifications to iOS (I didn't test the case with FCM sending to android) and even if we set Sound: "default" the notification doesn't play any sound (it is shown on the iPhone correctly though).

You can reproduce using the following test case

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/appleboy/gorush/rpc/proto"
    "google.golang.org/grpc"
)

func Connect() proto.GorushClient {
    // Set up a connection to the server.
    conn, err := grpc.Dial("localhost:9000", grpc.WithInsecure())
    if err != nil {
        log.Fatalf("did not connect: %v", err)
    }
    return proto.NewGorushClient(conn)
}

func main() {
    gorushClient := Connect()

    ctx := context.Background()
    res, _ := gorushClient.Send(ctx, &proto.NotificationRequest{
        Platform:         2,
        Title:            "TEST",
        Message:          "test",
        Priority:         proto.NotificationRequest_HIGH,
        PushType:         "alert",
        MutableContent:   true,
        ContentAvailable: true,
        Sound:            "default",
        Tokens:           []string{"TOKEN_OMITTED"},
    })

    fmt.Println("Sent notification:", res)
}

Running this test case against gorush 1.16 sends a notification with sound, while using gorush 1.18 the notification arrives without sound.

appleboy commented 1 week ago

I will take it and some refer to https://github.com/appleboy/gorush/issues/788