Skip to content

Commit 6381676

Browse files
committed
feat: add support for InterruptionLevel in iOS notifications
1 parent 26dec0b commit 6381676

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

messaging/messaging.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -721,16 +721,17 @@ func (p *APNSPayload) UnmarshalJSON(b []byte) error {
721721
// Alert may be specified as a string (via the AlertString field), or as a struct (via the Alert
722722
// field).
723723
type Aps struct {
724-
AlertString string `json:"-"`
725-
Alert *ApsAlert `json:"-"`
726-
Badge *int `json:"badge,omitempty"`
727-
Sound string `json:"-"`
728-
CriticalSound *CriticalSound `json:"-"`
729-
ContentAvailable bool `json:"-"`
730-
MutableContent bool `json:"-"`
731-
Category string `json:"category,omitempty"`
732-
ThreadID string `json:"thread-id,omitempty"`
733-
CustomData map[string]interface{} `json:"-"`
724+
AlertString string `json:"-"`
725+
Alert *ApsAlert `json:"-"`
726+
Badge *int `json:"badge,omitempty"`
727+
Sound string `json:"-"`
728+
CriticalSound *CriticalSound `json:"-"`
729+
ContentAvailable bool `json:"-"`
730+
MutableContent bool `json:"-"`
731+
InterruptionLevel InterruptionLevel `json:"interruption-level,omitempty"`
732+
Category string `json:"category,omitempty"`
733+
ThreadID string `json:"thread-id,omitempty"`
734+
CustomData map[string]interface{} `json:"-"`
734735
}
735736

736737
// standardFields creates a map containing all the fields except the custom data.
@@ -858,6 +859,23 @@ func (cs *CriticalSound) UnmarshalJSON(b []byte) error {
858859
return nil
859860
}
860861

862+
// InterruptionLevel indicates the importance and delivery timing of a notification. Available on iOS 15+.
863+
type InterruptionLevel string
864+
865+
const (
866+
// InterruptionLevelActive presents notifications immediately, lights up the screen, and can play a sound.
867+
InterruptionLevelActive InterruptionLevel = "active"
868+
869+
// InterruptionLevelCritical presents the notification immediately, lights up the screen, and bypasses the mute switch to play a sound.
870+
InterruptionLevelCritical InterruptionLevel = "critical"
871+
872+
// InterruptionLevelPassive adds the notification to the notification list without lighting up the screen or playing a sound.
873+
InterruptionLevelPassive InterruptionLevel = "passive"
874+
875+
// InterruptionLevelTimeSensitive presents the notification immediately, lights up the screen, can play a sound, and breaks through system notification controls.
876+
InterruptionLevelTimeSensitive InterruptionLevel = "time-sensitive"
877+
)
878+
861879
// ApsAlert is the alert payload that can be included in an Aps.
862880
//
863881
// See https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html

0 commit comments

Comments
 (0)