Documentation
¶
Overview ¶
Package notifications provides a push notification sending interface with implementations for APNs and FCM.
Example (NoopPushNotificationSender) ¶
package main
import (
"context"
"fmt"
"github.com/verygoodsoftwarenotvirus/platform/v2/notifications"
)
func main() {
sender := ¬ifications.NoopPushNotificationSender{}
err := sender.SendPush(context.Background(), "ios", "device-token-abc", notifications.PushMessage{
Title: "New Message",
Body: "You have a new message!",
})
fmt.Println(err)
}
Output: <nil>
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPlatformNotSupported = errors.New("push notifications not configured for this platform")
ErrPlatformNotSupported is returned when attempting to send to a platform that has no configured sender (e.g., iOS token but APNs not configured).
Functions ¶
This section is empty.
Types ¶
type MobileNotificationRequest ¶
type MobileNotificationRequest struct {
Context map[string]string `json:"context,omitempty"`
BadgeCount *int `json:"badgeCount,omitempty"`
RequestType string `json:"requestType"`
Title string `json:"title"`
Body string `json:"body"`
TestID string `json:"testID,omitempty"`
RecipientUserIDs []string `json:"recipientUserIDs"`
}
MobileNotificationRequest is the generic message payload for mobile push notifications. RequestType determines which handler processes the request; schedulers format the message.
type MultiPlatformPushSender ¶
type MultiPlatformPushSender struct {
// contains filtered or unexported fields
}
MultiPlatformPushSender routes push notifications to APNs (iOS) or FCM (Android).
func NewMultiPlatformPushSender ¶
func NewMultiPlatformPushSender( apnsSender *apns.Sender, fcmSender *fcm.Sender, logger logging.Logger, tracerProvider tracing.TracerProvider, ) *MultiPlatformPushSender
NewMultiPlatformPushSender creates a sender that routes by platform.
func (*MultiPlatformPushSender) SendPush ¶
func (s *MultiPlatformPushSender) SendPush(ctx context.Context, platform, token string, msg PushMessage) error
SendPush sends a push notification to a single device token, routing by platform.
type NoopPushNotificationSender ¶
type NoopPushNotificationSender struct{}
NoopPushNotificationSender is a no-op implementation of PushNotificationSender. It does not send any push notifications; used when APNs/FCM is not yet integrated.
func (*NoopPushNotificationSender) SendPush ¶
func (n *NoopPushNotificationSender) SendPush(_ context.Context, _, _ string, _ PushMessage) error
SendPush is a no-op; it does not send any notifications.
type PushMessage ¶
PushMessage holds the content of a push notification. BadgeCount is optional; when non-nil on iOS, sets the app icon badge.
type PushNotificationSender ¶
type PushNotificationSender interface {
// SendPush sends a push notification to a single device token.
// platform is "ios" or "android"; implementations filter by platform.
SendPush(ctx context.Context, platform, token string, msg PushMessage) error
}
PushNotificationSender sends push notifications to device tokens. Implementations route by platform: APNs for ios, FCM for android.