@@ -5,68 +5,107 @@ import (
5
5
"time"
6
6
)
7
7
8
- //EPushType defines the value for the apns-push-type header
8
+ // EPushType defines the value for the apns-push-type header
9
9
type EPushType string
10
10
11
11
const (
12
- //PushTypeAlert will set the apns-push-type header to 'alert'
12
+ // PushTypeAlert is used for notifications that trigger a user interaction —
13
+ // for example, an alert, badge, or sound. If you set this push type, the
14
+ // apns-topic header field must use your app’s bundle ID as the topic. The
15
+ // alert push type is required on watchOS 6 and later. It is recommended on
16
+ // macOS, iOS, tvOS, and iPadOS.
13
17
PushTypeAlert EPushType = "alert"
14
- //PushTypeBackground will set the apns-push-type header to 'background'
18
+
19
+ // PushTypeBackground is used for notifications that deliver content in the
20
+ // background, and don’t trigger any user interactions. If you set this push
21
+ // type, the apns-topic header field must use your app’s bundle ID as the
22
+ // topic. The background push type is required on watchOS 6 and later. It is
23
+ // recommended on macOS, iOS, tvOS, and iPadOS.
15
24
PushTypeBackground EPushType = "background"
16
- //PushTypeVoIP will set the apns-push-type header to 'voip' which is required
17
- // for PushKit applications.
18
- PushTypeVoIP EPushType = "voip"
25
+
26
+ // PushTypeVOIP is used for notifications that provide information about an
27
+ // incoming Voice-over-IP (VoIP) call. If you set this push type, the
28
+ // apns-topic header field must use your app’s bundle ID with .voip appended
29
+ // to the end. If you’re using certificate-based authentication, you must
30
+ // also register the certificate for VoIP services. The voip push type is
31
+ // not available on watchOS. It is recommended on macOS, iOS, tvOS, and
32
+ // iPadOS.
33
+ PushTypeVOIP EPushType = "voip"
34
+
35
+ // PushTypeComplication is used for notifications that contain update
36
+ // information for a watchOS app’s complications. If you set this push type,
37
+ // the apns-topic header field must use your app’s bundle ID with
38
+ // .complication appended to the end. If you’re using certificate-based
39
+ // authentication, you must also register the certificate for WatchKit
40
+ // services. The complication push type is recommended for watchOS and iOS.
41
+ // It is not available on macOS, tvOS, and iPadOS.
42
+ PushTypeComplication EPushType = "complication"
43
+
44
+ // PushTypeFileProvider is used to signal changes to a File Provider
45
+ // extension. If you set this push type, the apns-topic header field must
46
+ // use your app’s bundle ID with .pushkit.fileprovider appended to the end.
47
+ // The fileprovider push type is not available on watchOS. It is recommended
48
+ // on macOS, iOS, tvOS, and iPadOS.
49
+ PushTypeFileProvider EPushType = "fileprovider"
50
+
51
+ // PushTypeMDM is used for notifications that tell managed devices to
52
+ // contact the MDM server. If you set this push type, you must use the topic
53
+ // from the UID attribute in the subject of your MDM push certificate.
54
+ PushTypeMDM EPushType = "mdm"
19
55
)
20
56
21
57
const (
22
58
// PriorityLow will tell APNs to send the push message at a time that takes
23
59
// into account power considerations for the device. Notifications with this
24
- // priority might be grouped and delivered in bursts. They are throttled, and
25
- // in some cases are not delivered.
60
+ // priority might be grouped and delivered in bursts. They are throttled,
61
+ // and in some cases are not delivered.
26
62
PriorityLow = 5
27
63
28
64
// PriorityHigh will tell APNs to send the push message immediately.
29
- // Notifications with this priority must trigger an alert, sound, or badge on
30
- // the target device. It is an error to use this priority for a push
65
+ // Notifications with this priority must trigger an alert, sound, or badge
66
+ // on the target device. It is an error to use this priority for a push
31
67
// notification that contains only the content-available key.
32
68
PriorityHigh = 10
33
69
)
34
70
35
71
// Notification represents the the data and metadata for a APNs Remote Notification.
36
72
type Notification struct {
37
73
38
- // An optional canonical UUID that identifies the notification. The canonical
39
- // form is 32 lowercase hexadecimal digits, displayed in five groups separated
40
- // by hyphens in the form 8-4-4-4-12. An example UUID is as follows:
74
+ // An optional canonical UUID that identifies the notification. The
75
+ // canonical form is 32 lowercase hexadecimal digits, displayed in five
76
+ // groups separated by hyphens in the form 8-4-4-4-12. An example UUID is as
77
+ // follows:
41
78
//
42
- // 123e4567-e89b-12d3-a456-42665544000
79
+ // 123e4567-e89b-12d3-a456-42665544000
43
80
//
44
81
// If you don't set this, a new UUID is created by APNs and returned in the
45
82
// response.
46
83
ApnsID string
47
84
48
- // A string which allows multiple notifications with the same collapse identifier
49
- // to be displayed to the user as a single notification. The value should not
50
- // exceed 64 bytes.
85
+ // A string which allows multiple notifications with the same collapse
86
+ // identifier to be displayed to the user as a single notification. The
87
+ // value should not exceed 64 bytes.
51
88
CollapseID string
52
89
53
- // A string containing hexadecimal bytes of the device token for the target device.
90
+ // A string containing hexadecimal bytes of the device token for the target
91
+ // device.
54
92
DeviceToken string
55
93
56
- // The topic of the remote notification, which is typically the bundle ID for
57
- // your app. The certificate you create in the Apple Developer Member Center
58
- // must include the capability for this topic. If your certificate includes
59
- // multiple topics, you must specify a value for this header. If you omit this
60
- // header and your APNs certificate does not specify multiple topics, the APNs
61
- // server uses the certificate’s Subject as the default topic.
94
+ // The topic of the remote notification, which is typically the bundle ID
95
+ // for your app. The certificate you create in the Apple Developer Member
96
+ // Center must include the capability for this topic. If your certificate
97
+ // includes multiple topics, you must specify a value for this header. If
98
+ // you omit this header and your APNs certificate does not specify multiple
99
+ // topics, the APNs server uses the certificate’s Subject as the default
100
+ // topic.
62
101
Topic string
63
102
64
103
// An optional time at which the notification is no longer valid and can be
65
104
// discarded by APNs. If this value is in the past, APNs treats the
66
105
// notification as if it expires immediately and does not store the
67
106
// notification or attempt to redeliver it. If this value is left as the
68
- // default (ie, Expiration.IsZero()) an expiration header will not added to the
69
- // http request.
107
+ // default (ie, Expiration.IsZero()) an expiration header will not added to
108
+ // the http request.
70
109
Expiration time.Time
71
110
72
111
// The priority of the notification. Specify ether apns.PriorityHigh (10) or
@@ -79,8 +118,9 @@ type Notification struct {
79
118
// Remote Notification Programming Guide for more info.
80
119
Payload interface {}
81
120
82
- // The pushtype of the push notification. If this values is left as the default
83
- // an apns-push-type header with value 'alert' will be added to the http request.
121
+ // The pushtype of the push notification. If this values is left as the
122
+ // default an apns-push-type header with value 'alert' will be added to the
123
+ // http request.
84
124
PushType EPushType
85
125
}
86
126
0 commit comments