Skip to content

[Question]: GetRecipients() returns 0 on successful delivery with include_external_user_ids #54

@1plam

Description

@1plam

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?

  1. Is it intentional for GetRecipients() to return 0?
  2. Is there a potential delay before the recipients count is accurately reflected in the response?
  3. 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-empty id (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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions