Skip to main content

SendPush

The SendPush method sends a push notification to a user's registered device.

Usage​

err := client.SendPush(ctx, payload)

Parameters​

NameTypeDescription
ctxcontext.ContextContext for the request.
payloadcdp.PushPayloadStruct containing push notification details.

PushPayload Struct​

FieldTypeRequiredDescription
Identifierscdp.Identifiers✅User identifiers (exactly one of ID, Email, or CioID).
TransactionalMessageIDstring✅ID of the push message template.
TitlestringNotification title (overrides template).
BodystringNotification body text (overrides template).
MessageDatamap[string]interface{}Data for template variables or deep linking.

Validation Rules​

  • Identifiers must contain exactly one of: ID, Email, or CioID
  • TransactionalMessageID is required
  • Body cannot be an empty string if provided

Dual-Write Behavior​

Push NOT Forwarded to Customer.io

Push notifications are not sent to Customer.io even when dual-write is enabled. This prevents duplicate notifications.

Example​

payload := cdp.PushPayload{
Identifiers: cdp.Identifiers{ID: "user_123"},
TransactionalMessageID: "promo_push",
Title: "Flash Sale!",
Body: "50% off everything today.",
MessageData: map[string]interface{}{
"deep_link": "app://sale/50off",
},
}

if err := client.SendPush(context.Background(), payload); err != nil {
log.Println("Error sending push:", err)
}