payload

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package payload serializes a JSON payload to push.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncomplete = errors.New("payload does not contain necessary fields")
)

validation errors

Functions

This section is empty.

Types

type APS

type APS struct {
	// Alert dictionary.
	Alert Alert

	// Badge to display on the app icon.
	// Set to badge.Preserve (default), badge.Clear
	// or a specific value with badge.New(n).
	Badge badge.Badge

	// The name of a sound file to play as an alert.
	Sound string

	// Content available for silent notifications.
	// With no alert, sound, or badge.
	ContentAvailable bool

	// Category identifier for custom actions in iOS 8 or newer.
	Category string
}

APS is Apple's reserved namespace.

func (*APS) Map

func (a *APS) Map() map[string]interface{}

Map returns the APS payload as a map that you can customize before serializing it to JSON. TODO: Make this map implement json.Marshaler for use with Service.Push.

func (APS) MarshalJSON

func (a APS) MarshalJSON() ([]byte, error)

MarshalJSON allows you to json.Marshal(aps) directly.

func (*APS) Validate added in v0.3.0

func (a *APS) Validate() error

Validate APS payload.

type Alert

type Alert struct {
	// Title is a short string shown briefly on Apple Watch in iOS 8.2 or newer.
	Title        string   `json:"title,omitempty"`
	TitleLocKey  string   `json:"title-loc-key,omitempty"`
	TitleLocArgs []string `json:"title-loc-args,omitempty"`

	// Body text of the alert message.
	Body    string   `json:"body,omitempty"`
	LocKey  string   `json:"loc-key,omitempty"`
	LocArgs []string `json:"loc-args,omitempty"`

	// Key for localized string for "View" button.
	ActionLocKey string `json:"action-loc-key,omitempty"`

	// Image file to be used when user taps or slides the action button.
	LaunchImage string `json:"launch-image,omitempty"`
}

Alert dictionary.

type Browser added in v0.2.0

type Browser struct {
	// Alert dictionary.
	Alert   BrowserAlert
	URLArgs []string
}

Browser for Safari Push Notifications

func (Browser) MarshalJSON added in v0.2.0

func (p Browser) MarshalJSON() ([]byte, error)

MarshalJSON allows you to json.Marshal(browser) directly.

func (*Browser) Validate added in v0.3.0

func (p *Browser) Validate() error

Validate browser payload.

type BrowserAlert added in v0.2.0

type BrowserAlert struct {
	// Title and Body are required
	Title string `json:"title"`
	Body  string `json:"body"`
	// Action button label (defaults to "Show")
	Action string `json:"action,omitempty"`
}

BrowserAlert for Safari Push Notifications

type MDM

type MDM struct {
	Token string `json:"mdm"`
}

MDM payload for mobile device management.

func (*MDM) Validate added in v0.3.0

func (p *MDM) Validate() error

Validate MDM payload.

Directories

Path Synopsis
Package badge allows you to preserve, set or clear the number displayed on your App icon.
Package badge allows you to preserve, set or clear the number displayed on your App icon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL