Documentation ¶
Overview ¶
Package payload is a helper package which contains a payload builder to make constructing notification payloads easier.
Index ¶
- type Payload
- func (p *Payload) Alert(alert interface{}) *Payload
- func (p *Payload) AlertAction(action string) *Payload
- func (p *Payload) AlertActionLocKey(key string) *Payload
- func (p *Payload) AlertBody(body string) *Payload
- func (p *Payload) AlertLaunchImage(image string) *Payload
- func (p *Payload) AlertLocArgs(args []string) *Payload
- func (p *Payload) AlertLocKey(key string) *Payload
- func (p *Payload) AlertSubtitle(subtitle string) *Payload
- func (p *Payload) AlertTitle(title string) *Payload
- func (p *Payload) AlertTitleLocArgs(args []string) *Payload
- func (p *Payload) AlertTitleLocKey(key string) *Payload
- func (p *Payload) Badge(b int) *Payload
- func (p *Payload) Category(category string) *Payload
- func (p *Payload) ContentAvailable() *Payload
- func (p *Payload) Custom(key string, val interface{}) *Payload
- func (p *Payload) MarshalJSON() ([]byte, error)
- func (p *Payload) Mdm(mdm string) *Payload
- func (p *Payload) MutableContent() *Payload
- func (p *Payload) Sound(sound string) *Payload
- func (p *Payload) ThreadID(threadID string) *Payload
- func (p *Payload) URLArgs(urlArgs []string) *Payload
- func (p *Payload) UnsetBadge() *Payload
- func (p *Payload) ZeroBadge() *Payload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Payload ¶
type Payload struct {
// contains filtered or unexported fields
}
Payload represents a notification which holds the content that will be marshalled as JSON.
func (*Payload) Alert ¶
Alert sets the aps alert on the payload. This will display a notification alert message to the user.
{"aps":{"alert":alert}}`
func (*Payload) AlertAction ¶
AlertAction sets the aps alert action on the payload. This is the label of the action button, if the user sets the notifications to appear as alerts. This label should be succinct, such as “Details” or “Read more”. If omitted, the default value is “Show”.
{"aps":{"alert":{"action":action}}}
func (*Payload) AlertActionLocKey ¶
AlertActionLocKey sets the aps alert action localization key on the payload. This is the the string used as a key to get a localized string in the current localization to use for the notfication right button’s title instead of “View”. See Localized Formatted Strings in Apple documentation for more information.
{"aps":{"alert":{"action-loc-key":key}}}
func (*Payload) AlertBody ¶
AlertBody sets the aps alert body on the payload. This is the text of the alert message.
{"aps":{"alert":{"body":body}}}
func (*Payload) AlertLaunchImage ¶
AlertLaunchImage sets the aps launch image on the payload. This is the filename of an image file in the app bundle. The image is used as the launch image when users tap the action button or move the action slider.
{"aps":{"alert":{"launch-image":image}}}
func (*Payload) AlertLocArgs ¶
AlertLocArgs sets the aps alert localization args on the payload. These are the variable string values to appear in place of the format specifiers in loc-key. See Localized Formatted Strings in Apple documentation for more information.
{"aps":{"alert":{"loc-args":args}}}
func (*Payload) AlertLocKey ¶
AlertLocKey sets the aps alert localization key on the payload. This is the key to an alert-message string in the Localizable.strings file for the current localization. See Localized Formatted Strings in Apple documentation for more information.
{"aps":{"alert":{"loc-key":key}}}
func (*Payload) AlertSubtitle ¶
AlertSubtitle sets the aps alert subtitle on the payload. This will display a short string describing the purpose of the notification. Apple Watch & Safari display this string as part of the notification interface.
{"aps":{"subtitle":"subtitle"}}
func (*Payload) AlertTitle ¶
AlertTitle sets the aps alert title on the payload. This will display a short string describing the purpose of the notification. Apple Watch & Safari display this string as part of the notification interface.
{"aps":{"alert":{"title":title}}}
func (*Payload) AlertTitleLocArgs ¶
AlertTitleLocArgs sets the aps alert title localization args on the payload. These are the variable string values to appear in place of the format specifiers in title-loc-key. See Localized Formatted Strings in Apple documentation for more information.
{"aps":{"alert":{"title-loc-args":args}}}
func (*Payload) AlertTitleLocKey ¶
AlertTitleLocKey sets the aps alert title localization key on the payload. This is the key to a title string in the Localizable.strings file for the current localization. See Localized Formatted Strings in Apple documentation for more information.
{"aps":{"alert":{"title-loc-key":key}}}
func (*Payload) Badge ¶
Badge sets the aps badge on the payload. This will display a numeric badge on the app icon.
{"aps":{"badge":b}}
func (*Payload) Category ¶
Category sets the aps category on the payload. This is a string value that represents the identifier property of the UIMutableUserNotificationCategory object you created to define custom actions.
{"aps":{"alert":{"category":category}}}
func (*Payload) ContentAvailable ¶
ContentAvailable sets the aps content-available on the payload to 1. This will indicate to the app that there is new content available to download and launch the app in the background.
{"aps":{"content-available":1}}
func (*Payload) Custom ¶
Custom sets a custom key and value on the payload. This will add custom key/value data to the notification payload at root level.
{"aps":{}, key:value}
func (*Payload) MarshalJSON ¶
MarshalJSON returns the JSON encoded version of the Payload
func (*Payload) Mdm ¶
Mdm sets the mdm on the payload. This is for Apple Mobile Device Management (mdm) payloads.
{"aps":{}:"mdm":mdm}
func (*Payload) MutableContent ¶
MutableContent sets the aps mutable-content on the payload to 1. This will indicate to the to the system to call your Notification Service extension to mutate or replace the notification's content.
{"aps":{"mutable-content":1}}
func (*Payload) Sound ¶
Sound sets the aps sound on the payload. This will play a sound from the app bundle, or the default sound otherwise.
{"aps":{"sound":sound}}
func (*Payload) ThreadID ¶
ThreadID sets the aps thread id on the payload. This is for the purpose of updating the contents of a View Controller in a Notification Content app extension when a new notification arrives. If a new notification arrives whose thread-id value matches the thread-id of the notification already being displayed, the didReceiveNotification method is called.
{"aps":{"thread-id":id}}
func (*Payload) URLArgs ¶
URLArgs sets the aps category on the payload. This specifies an array of values that are paired with the placeholders inside the urlFormatString value of your website.json file. See Apple Notification Programming Guide for Websites.
{"aps":{"url-args":urlArgs}}
func (*Payload) UnsetBadge ¶
UnsetBadge removes the badge attribute from the payload. This will leave the badge on the app icon unchanged. If you wish to clear the app icon badge, use ZeroBadge() instead.
{"aps":{}}