diff --git a/gorush/notification_apns.go b/gorush/notification_apns.go index 17c81f8..5d1b8cd 100644 --- a/gorush/notification_apns.go +++ b/gorush/notification_apns.go @@ -204,6 +204,9 @@ func GetIOSNotification(req PushNotification) *apns2.Notification { result := &Sound{} _ = mapstructure.Decode(req.Sound, &result) payload.Sound(result) + // from http request binding for non critical alerts + case string: + payload.Sound(&req.Sound) case Sound: payload.Sound(&req.Sound) } diff --git a/gorush/notification_apns_test.go b/gorush/notification_apns_test.go index ff5eaba..d3b3c48 100644 --- a/gorush/notification_apns_test.go +++ b/gorush/notification_apns_test.go @@ -197,6 +197,25 @@ func TestIOSSoundAndVolume(t *testing.T) { assert.Equal(t, 4.5, soundVolume) assert.Equal(t, int64(3), soundCritical) assert.Equal(t, "test", soundName) + + req = PushNotification{ + ApnsID: test, + Topic: test, + Priority: "normal", + Message: message, + Sound: "default", + } + + notification = GetIOSNotification(req) + dump, _ = json.Marshal(notification.Payload) + data = []byte(string(dump)) + + if err := json.Unmarshal(data, &dat); err != nil { + panic(err) + } + + soundName, _ = jsonparser.GetString(data, "aps", "sound") + assert.Equal(t, "default", soundName) } func TestIOSSummaryArg(t *testing.T) {