chat: Index | Files

package fcm

import ""

Package fcm implements push notification plugin for Google FCM backend. Push notifications for Android, iOS and web clients are sent through Google's Firebase Cloud Messaging service. Package fcm is push notification plugin using Google FCM.


Package Files

payload.go push_fcm.go

func DevicesForUser Uses

func DevicesForUser(uid t.Uid) []string

DevicesForUser loads device IDs of the given user.

type AndroidConfig Uses

type AndroidConfig struct {
    Enabled bool `json:"enabled,omitempty"`

    // Configs for specific push types.
    Msg androidPayload `json:"msg,omitempty"`
    Sub androidPayload `json:"sub,omitempty"`
    // contains filtered or unexported fields

AndroidConfig is the configuration of AndroidNotification payload.

type Handler Uses

type Handler struct {
    // contains filtered or unexported fields

Handler represents the push handler; implements push.PushHandler interface.

func (Handler) Channel Uses

func (Handler) Channel() chan<- *push.ChannelReq

Channel returns a channel for subscribing/unsubscribing devices to FCM topics.

func (Handler) Init Uses

func (Handler) Init(jsonconf string) error

Init initializes the push handler

func (Handler) IsReady Uses

func (Handler) IsReady() bool

IsReady checks if the push handler has been initialized.

func (Handler) Push Uses

func (Handler) Push() chan<- *push.Receipt

Push returns a channel that the server will use to send messages to. If the adapter blocks, the message will be dropped.

func (Handler) Stop Uses

func (Handler) Stop()

Stop shuts down the handler

type MessageData Uses

type MessageData struct {
    Uid t.Uid
    // FCM device token.
    DeviceId string
    Message  *fcm.Message

MessageData adds user ID and device token to push message. This is needed for error handling.

func PrepareNotifications Uses

func PrepareNotifications(rcpt *push.Receipt, config *AndroidConfig) []MessageData

PrepareNotifications creates notification payloads ready to be posted to push notification server for the provided receipt.

Package fcm imports 14 packages (graph) and is imported by 5 packages. Updated 2021-01-18. Refresh now. Tools for package owners.