Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions messaging/messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ type Notification struct {

// AndroidConfig contains messaging options specific to the Android platform.
type AndroidConfig struct {
CollapseKey string `json:"collapse_key,omitempty"`
Priority string `json:"priority,omitempty"` // one of "normal" or "high"
TTL *time.Duration `json:"-"`
RestrictedPackageName string `json:"restricted_package_name,omitempty"`
Data map[string]string `json:"data,omitempty"` // if specified, overrides the Data field on Message type
Notification *AndroidNotification `json:"notification,omitempty"`
FCMOptions *AndroidFCMOptions `json:"fcm_options,omitempty"`
DirectBootOK bool `json:"direct_boot_ok,omitempty"`
CollapseKey string `json:"collapse_key,omitempty"`
Priority string `json:"priority,omitempty"` // one of "normal" or "high"
TTL *time.Duration `json:"-"`
RestrictedPackageName string `json:"restricted_package_name,omitempty"`
Data map[string]string `json:"data,omitempty"` // if specified, overrides the Data field on Message type
Notification *AndroidNotification `json:"notification,omitempty"`
FCMOptions *AndroidFCMOptions `json:"fcm_options,omitempty"`
DirectBootOK bool `json:"direct_boot_ok,omitempty"`
BandwidthConstrainedOK bool `json:"bandwidth_constrained_ok,omitempty"`
RestrictedSatelliteOK bool `json:"restricted_satellite_ok,omitempty"`
}

// MarshalJSON marshals an AndroidConfig into JSON (for internal use only).
Expand Down
14 changes: 9 additions & 5 deletions messaging/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ var validMessages = []struct {
},
},
{
name: "AndroidDataMessage",
name: "AndroidDataMessageWithBooleanOptions",
req: &Message{
Android: &AndroidConfig{
DirectBootOK: true,
CollapseKey: "ck",
DirectBootOK: true,
BandwidthConstrainedOK: true,
RestrictedSatelliteOK: true,
CollapseKey: "ck",
Data: map[string]string{
"k1": "v1",
"k2": "v2",
Expand All @@ -161,8 +163,10 @@ var validMessages = []struct {
},
want: map[string]interface{}{
"android": map[string]interface{}{
"direct_boot_ok": true,
"collapse_key": "ck",
"direct_boot_ok": true,
"bandwidth_constrained_ok": true,
"restricted_satellite_ok": true,
"collapse_key": "ck",
"data": map[string]interface{}{
"k1": "v1",
"k2": "v2",
Expand Down
Loading