|
|
@ -40,13 +40,12 @@ type Fcm struct {
|
|
|
|
|
|
|
|
|
|
|
|
// NewClient initializes a new FCM client using the Firebase Admin SDK.
|
|
|
|
// NewClient initializes a new FCM client using the Firebase Admin SDK.
|
|
|
|
// It requires the FCM service account credentials file located within the project's configuration directory.
|
|
|
|
// It requires the FCM service account credentials file located within the project's configuration directory.
|
|
|
|
func NewClient(pushConf *config.Push, cache cache.ThirdCache, fcmPath string) (*Fcm, error) {
|
|
|
|
func NewClient(pushConf *config.Push, cache cache.ThirdCache, fcmConfigPath string) (*Fcm, error) {
|
|
|
|
//projectRoot, err := config.GetProjectRoot()
|
|
|
|
//projectRoot, err := config.GetProjectRoot()
|
|
|
|
//if err != nil {
|
|
|
|
//if err != nil {
|
|
|
|
// return nil, err
|
|
|
|
// return nil, err
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
projectRoot := fcmPath
|
|
|
|
credentialsFilePath := filepath.Join(fcmConfigPath, pushConf.FCM.ServiceAccount)
|
|
|
|
credentialsFilePath := filepath.Join(projectRoot, pushConf.FCM.ServiceAccount)
|
|
|
|
|
|
|
|
opt := option.WithCredentialsFile(credentialsFilePath)
|
|
|
|
opt := option.WithCredentialsFile(credentialsFilePath)
|
|
|
|
fcmApp, err := firebase.NewApp(context.Background(), nil, opt)
|
|
|
|
fcmApp, err := firebase.NewApp(context.Background(), nil, opt)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|