fix: wake app for call pushes

This commit is contained in:
richjohnrambo
2026-09-18 13:51:22 +08:00
parent 153f541078
commit 9482bb19f6
3 changed files with 25 additions and 12 deletions
+19 -10
View File
@@ -79,11 +79,12 @@ type androidPayload struct {
}
type iosPayload struct {
Alert iosAlert `json:"alert"`
Sound string `json:"sound,omitempty"`
Badge string `json:"badge,omitempty"`
Category string `json:"category,omitempty"`
Extras map[string]string `json:"extras,omitempty"`
Alert iosAlert `json:"alert"`
Sound string `json:"sound,omitempty"`
Badge string `json:"badge,omitempty"`
Category string `json:"category,omitempty"`
ContentAvailable int `json:"content-available,omitempty"`
Extras map[string]string `json:"extras,omitempty"`
}
type iosAlert struct {
@@ -501,11 +502,12 @@ func buildPayload(audience map[string][]string, topic string, data map[string]st
Priority: 1,
},
IOS: &iosPayload{
Alert: iosAlert{Title: title, Body: alert},
Sound: "default",
Badge: badge,
Category: iosCategory(data),
Extras: data,
Alert: iosAlert{Title: title, Body: alert},
Sound: "default",
Badge: badge,
Category: iosCategory(data),
ContentAvailable: iosContentAvailable(data),
Extras: data,
},
HMOS: &hmosPayload{
Title: title,
@@ -548,6 +550,13 @@ func iosCategory(data map[string]string) string {
return ""
}
func iosContentAvailable(data map[string]string) int {
if data["type"] == "call_invite" {
return 1
}
return 0
}
func hydrateCallInviteData(tenantID t.TenantID, data map[string]string) {
if data["type"] != "call_invite" || strings.TrimSpace(data["caller_display"]) != "" {
return
+3
View File
@@ -190,6 +190,9 @@ func TestBuildPayloadUsesShortTTLForCalls(t *testing.T) {
if payload.Notification.IOS.Category != callCategory {
t.Fatalf("unexpected iOS category: %s", payload.Notification.IOS.Category)
}
if payload.Notification.IOS.ContentAvailable != 1 {
t.Fatalf("unexpected iOS content-available: %d", payload.Notification.IOS.ContentAvailable)
}
if payload.Notification.IOS.Alert.Body != "张三邀请你语音通话" {
t.Fatalf("unexpected body: %s", payload.Notification.IOS.Alert.Body)
}