Skip to content

Commit

Permalink
print receiver, unique id and count only 200 apns requests
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad2002 committed Dec 4, 2024
1 parent 4848f09 commit 4ac7451
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions service/notification_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func SendPushNotificationForMeeting(meeting string, title string, subtitle strin
wg.Add(1)
go func(receiver string, title string, subtitle string, message string, success *int) {
defer wg.Done()
_, _, _, err := SendPushNotification(receiver, title, subtitle, message)
if err == nil {
_, _, code, err := SendPushNotification(receiver, title, subtitle, message)
if err == nil || code == 200 {
*success++
}
}(user.Token, title, subtitle, message, &success)
Expand Down Expand Up @@ -129,6 +129,8 @@ func SendPushNotification(receiver string, title string, subtitle string, messag
}
`)

fmt.Printf("notifying user with token: '%s'\n", receiver)

r, err := http.NewRequest("POST", apnsUrl+"/3/device/"+receiver, bytes.NewBuffer(b))
if err != nil {
fmt.Println(err)
Expand All @@ -155,8 +157,8 @@ func SendPushNotification(receiver string, title string, subtitle string, messag
}
fmt.Println(string(body))

apnsID := resp.Header.Get("apns-id")
println("apns-id: " + apnsID)
apnsID := resp.Header.Get("apns-unique-id")
println("apns-unique-id: " + apnsID)

return apnsID, string(body), resp.StatusCode, nil
}

0 comments on commit 4ac7451

Please sign in to comment.