MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / FCMClient

Method FCMClient

api/pkg/di/container.go:543–560  ·  view source on GitHub ↗

FCMClient creates the appropriate FCM client based on configuration. When FCM_ENDPOINT is set, it returns an EmulatorFCMClient that sends notifications directly to the phone emulator via HTTP. Otherwise, it returns a FirebaseFCMClient that uses the real Firebase SDK.

()

Source from the content-addressed store, hash-verified

541// notifications directly to the phone emulator via HTTP.
542// Otherwise, it returns a FirebaseFCMClient that uses the real Firebase SDK.
543func (container *Container) FCMClient() services.FCMClient {
544 if fcmEndpoint := os.Getenv("FCM_ENDPOINT"); fcmEndpoint != "" {
545 container.logger.Info(fmt.Sprintf("using emulator FCM client with endpoint: %s", fcmEndpoint))
546 return services.NewEmulatorFCMClient(
547 container.HTTPClient("emulator_fcm"),
548 fcmEndpoint,
549 container.Logger(),
550 )
551 }
552
553 container.logger.Debug("creating FirebaseFCMClient")
554 messagingClient, err := container.FirebaseApp().Messaging(context.Background())
555 if err != nil {
556 msg := "cannot initialize firebase messaging client"
557 container.logger.Fatal(stacktrace.Propagate(err, msg))
558 }
559 return services.NewFirebaseFCMClient(messagingClient)
560}
561
562// FirebaseCredentials returns firebase credentials as bytes.
563func (container *Container) FirebaseCredentials() []byte {

Callers 1

NotificationServiceMethod · 0.95

Calls 6

HTTPClientMethod · 0.95
LoggerMethod · 0.95
FirebaseAppMethod · 0.95
InfoMethod · 0.65
DebugMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected