-
Notifications
You must be signed in to change notification settings - Fork 9
Description
How can we help?
Hey,
I have a question about the response from the createNotificationRequest.Execute()
when using the Go SDK (OneSignal/onesignal-go-api/v2 v2.2.1).
Goal
My goal is to reliably determine if a notification sent to a single user via include_external_user_ids
was successfully created or if it failed because the user ID was invalid. This allows my service to trigger fallbacks.
What I'm Doing
I'm creating a notification targeting a single, valid external_user_id
that I know could be subscribed and can receive notifications.
Observed Behavior
The push notification is delivered successfully to the user's device. The API returns a 200 OK
response and the CreateNotificationSuccessResponse
object contains a valid notification id
.
However, the recipients
field in the response is 0
.
My Question
I was planning to use the recipients
count as a primary indicator of a successful send, like this:
// Simplified logic
resp, httpResponse, err := client.CreateNotification(ctx).Execute()
// My check for logical failure (e.g., invalid user)
if resp.GetId() == "" || resp.GetRecipients() == 0 {
// This block gets triggered incorrectly because GetRecipients() returns 0,
// even though the notification was sent and resp.GetId() has a value.
log.Warn("Logical failure detected.")
}
Could you clarify the expected behavior here?
- Is it intentional for
GetRecipients()
to return0
? - Is there a potential delay before the
recipients
count is accurately reflected in the response? - What is the recommended, most reliable server-side method to confirm that a notification to a specific
external_user_id
has been successfully queued for delivery? I was thinking of just checking for the presence of a non-emptyid
(resp.GetId() != ""
), but it's definitely too generic and ain't covering my needs.
Thank you for your time and help!
Code of Conduct
- I agree to follow this project's Code of Conduct