go-univush: github.com/alash3al/go-univush Index | Files

package univush

import "github.com/alash3al/go-univush"

Index

Package Files

helpers.go notification.go response.go send.go

func CertBytes Uses

func CertBytes(bytes []byte, password string) (tls.Certificate, error)

CertBytes retuns a new certificate using a bytes

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client - a client connection manager

func NewAPNS2CLient Uses

func NewAPNS2CLient(ctx context.Context, cert []byte, passphrase string) (*Client, error)

NewAPNS2CLient - constructs a new APNS2 client

func NewFCMClient Uses

func NewFCMClient(ctx context.Context, appID, appToken string) (*Client, error)

NewFCMClient - constructs a new FCM client

func (*Client) Send Uses

func (c *Client) Send(ctx context.Context, n *Notification) (*ClientResponse, error)

Send - push the message

type ClientResponse Uses

type ClientResponse struct {
    ID   string
    Code int
    Sent bool
}

ClientResponse - client response

func NewClientResponseFromAPNS2 Uses

func NewClientResponseFromAPNS2(resp *apns2.Response) *ClientResponse

NewClientResponseFromAPNS2 - create a APNS2 response from client respose

func NewClientResponseFromFCM Uses

func NewClientResponseFromFCM(id string) *ClientResponse

NewClientResponseFromFCM - create a FCM response from client response

type ClientType Uses

type ClientType int

ClientType - the type of the client "fcm" or "apns2"

const (
    // ClientTypeFCM - FCM client
    ClientTypeFCM ClientType = 1

    // ClientTypeAPNS2 - APNS2 client
    ClientTypeAPNS2 ClientType = 2
)

type Notification Uses

type Notification struct {
    Title       string            `json:"title"`
    Body        string            `json:"body"`
    Icon        string            `json:"icon"`
    Sound       string            `json:"sound"`
    Key         string            `json:"key"`
    Priority    string            `json:"priority"`
    DeviceToken string            `json:"device_token"`
    DeviceApp   string            `json:"device_app"`
    OnClick     string            `json:"OnClick"`
    TTL         int               `json:"ttl"`
    CustomData  map[string]string `json:"custom_data"`
}

Notification - a universal notification format

func (Notification) ToAPNS Uses

func (n Notification) ToAPNS() *apns2.Notification

ToAPNS - transform the notification to APNS format

func (Notification) ToAndroid Uses

func (n Notification) ToAndroid() *messaging.Message

ToAndroid - transform the notification to android format

func (Notification) ToWeb Uses

func (n Notification) ToWeb() *messaging.Message

ToWeb - transform the notification to a webpush format

Package univush imports 12 packages (graph). Updated 2018-12-26. Refresh now. Tools for package owners.