File tree Expand file tree Collapse file tree 4 files changed +71
-1
lines changed Expand file tree Collapse file tree 4 files changed +71
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
2
3
+ - [ added] ` messaging.Aps ` type now supports critical sound in its payload.
4
+
3
5
# v3.5.0
4
6
5
7
- [ added] ` messaging.AndroidNotification ` type now supports ` channel_id ` .
6
8
- [ dropped] Dropped support for Go 1.8 and earlier.
7
9
- [ fixed] Fixing error handling in FCM. The SDK now checks the key
8
10
` type.googleapis.com/google.firebase.fcm.v1.FcmError ` to set error code.
9
11
- [ added] ` messaging.ApsAlert ` type now supports subtitle in its payload.
12
+ - [ added] ` messaging.WebpushConfig ` type now supports fcmOptions in its payload.
10
13
11
14
# v3.4.0
12
15
Original file line number Diff line number Diff line change @@ -350,6 +350,7 @@ type Aps struct {
350
350
Alert * ApsAlert
351
351
Badge * int
352
352
Sound string
353
+ CriticalSound * CriticalSound
353
354
ContentAvailable bool
354
355
MutableContent bool
355
356
Category string
@@ -374,7 +375,9 @@ func (a *Aps) standardFields() map[string]interface{} {
374
375
if a .Badge != nil {
375
376
m ["badge" ] = * a .Badge
376
377
}
377
- if a .Sound != "" {
378
+ if a .CriticalSound != nil {
379
+ m ["sound" ] = a .CriticalSound
380
+ } else if a .Sound != "" {
378
381
m ["sound" ] = a .Sound
379
382
}
380
383
if a .Category != "" {
@@ -395,6 +398,13 @@ func (a *Aps) MarshalJSON() ([]byte, error) {
395
398
return json .Marshal (m )
396
399
}
397
400
401
+ // CriticalSound is the sound payload that can be included in an Aps.
402
+ type CriticalSound struct {
403
+ Critical bool `json:"critical,omitempty"`
404
+ Name string `json:"name,omitempty"`
405
+ Volume float64 `json:"volume,omitempty"`
406
+ }
407
+
398
408
// ApsAlert is the alert payload that can be included in an Aps.
399
409
//
400
410
// See https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html
Original file line number Diff line number Diff line change @@ -329,6 +329,60 @@ var validMessages = []struct {
329
329
"topic" : "test-topic" ,
330
330
},
331
331
},
332
+ {
333
+ name : "APNSAlertCrticalSound" ,
334
+ req : & Message {
335
+ APNS : & APNSConfig {
336
+ Headers : map [string ]string {
337
+ "h1" : "v1" ,
338
+ "h2" : "v2" ,
339
+ },
340
+ Payload : & APNSPayload {
341
+ Aps : & Aps {
342
+ AlertString : "a" ,
343
+ Badge : & badge ,
344
+ Category : "c" ,
345
+ CriticalSound : & CriticalSound {
346
+ Critical : true ,
347
+ Name : "n" ,
348
+ Volume : 0.7 ,
349
+ },
350
+ ThreadID : "t" ,
351
+ ContentAvailable : true ,
352
+ MutableContent : true ,
353
+ },
354
+ CustomData : map [string ]interface {}{
355
+ "k1" : "v1" ,
356
+ "k2" : true ,
357
+ },
358
+ },
359
+ },
360
+ Topic : "test-topic" ,
361
+ },
362
+ want : map [string ]interface {}{
363
+ "apns" : map [string ]interface {}{
364
+ "headers" : map [string ]interface {}{"h1" : "v1" , "h2" : "v2" },
365
+ "payload" : map [string ]interface {}{
366
+ "aps" : map [string ]interface {}{
367
+ "alert" : "a" ,
368
+ "badge" : float64 (badge ),
369
+ "category" : "c" ,
370
+ "sound" : map [string ]interface {}{
371
+ "critical" : true ,
372
+ "name" : "n" ,
373
+ "volume" : float64 (0.7 ),
374
+ },
375
+ "thread-id" : "t" ,
376
+ "content-available" : float64 (1 ),
377
+ "mutable-content" : float64 (1 ),
378
+ },
379
+ "k1" : "v1" ,
380
+ "k2" : true ,
381
+ },
382
+ },
383
+ "topic" : "test-topic" ,
384
+ },
385
+ },
332
386
{
333
387
name : "APNSBadgeZero" ,
334
388
req : & Message {
Original file line number Diff line number Diff line change @@ -108,6 +108,9 @@ func validateAps(aps *Aps) error {
108
108
if aps .Alert != nil && aps .AlertString != "" {
109
109
return fmt .Errorf ("multiple alert specifications" )
110
110
}
111
+ if aps .CriticalSound != nil && aps .Sound != "" {
112
+ return fmt .Errorf ("multiple sound specifications" )
113
+ }
111
114
m := aps .standardFields ()
112
115
for k := range aps .CustomData {
113
116
if _ , contains := m [k ]; contains {
You can’t perform that action at this time.
0 commit comments